Changeset 4852
- Timestamp:
- 05/03/07 15:01:42 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework3/tags/framework-3.0/lib/rex/proto/http/client.rb
r4745 r4852 54 54 'uri_fake_end' => false, # bool 55 55 'uri_fake_params_start' => false, # bool 56 'header_folding' => false # bool 56 'header_folding' => false, # bool 57 'chunked_size' => 0 # integer 57 58 } 58 59 … … 82 83 'uri_fake_end' => 'bool', 83 84 'uri_fake_params_start' => 'bool', 84 'header_folding' => 'bool' 85 'header_folding' => 'bool', 86 'chunked_size' => 'integer' 85 87 } 86 88 end … … 169 171 c_path = opts['path_info'] 170 172 c_auth = opts['basic_auth'] || config['basic_auth'] || '' 171 173 172 174 uri = set_cgi(c_cgi) 173 175 qstr = c_qs … … 231 233 req += set_connection_header(c_conn) 232 234 req += set_extra_headers(c_head) 233 234 # TODO: 235 # * Implement chunked transfer 236 235 237 236 req += set_content_type_header(c_type) 238 237 req += set_content_len_header(pstr.length) 238 req += set_chunked_header() 239 239 req += set_raw_headers(c_rawh) 240 240 req += set_body(pstr) … … 300 300 ret = conn.put(req_string) 301 301 302 # Tell the remote side if we aren't pipelining303 conn.shutdown(::Socket::SHUT_WR) if (!pipelining?)304 305 302 ret 306 303 end … … 364 361 raise RuntimeError, resp.error, caller 365 362 end 363 select(nil, nil, nil, 0.10) 366 364 end 367 365 end … … 535 533 # 536 534 def set_body(data) 537 "\r\n" + data 535 return "\r\n" + data if self.config['chunked_size'] == 0 536 str = data.dup 537 chunked = '' 538 while str.size > 0 539 chunk = str.slice!(0,rand(self.config['chunked_size']) + 1) 540 chunked += sprintf("%x", chunk.size) + "\r\n" + chunk + "\r\n" 541 end 542 "\r\n" + chunked + "0\r\n\r\n" 538 543 end 539 544 … … 655 660 # 656 661 # Return the content length header 657 # TODO:658 # * Ignore this if chunked encoding is set659 662 def set_content_len_header(clen) 663 return "" if self.config['chunked_size'] > 0 660 664 set_formatted_header("Content-Length", clen) 661 665 end … … 689 693 buf 690 694 end 691 695 696 def set_chunked_header() 697 return "" if self.config['chunked_size'] == 0 698 set_formatted_header('Transfer-Encoding', 'chunked') 699 end 700 692 701 # 693 702 # Return a string of raw header data
