From 2ce5dfbd9dfddf98b00d7a5c025dfb7b5e221500 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Fri, 2 Apr 2010 03:27:45 +0000 Subject: merge revision(s) 26131: * lib/net/http.rb (HTTPGenericRequest#send_request_with_body_stream): increased encoding chunk size for POST request with body_stream (1K -> 16K). patched by Brian Candler. #1284. * test/net/http/test_post_io.rb: added for the patch. It's good if a patch comes with a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@27172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/http/test_post_io.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/net/http/test_post_io.rb (limited to 'test') diff --git a/test/net/http/test_post_io.rb b/test/net/http/test_post_io.rb new file mode 100644 index 0000000000..c4093f9347 --- /dev/null +++ b/test/net/http/test_post_io.rb @@ -0,0 +1,32 @@ +require 'test/unit' +require 'net/http' +require 'stringio' + +class HTTPPostIOTest < Test::Unit::TestCase + def test_post_io_chunk_size + t = nil + TCPServer.open("127.0.0.1", 0) {|serv| + _, port, _, _ = serv.addr + t = Thread.new { + begin + req = Net::HTTP::Post.new("/test.cgi") + req['Transfer-Encoding'] = 'chunked' + req.body_stream = StringIO.new("\0" * (16 * 1024 + 1)) + http = Net::HTTP.new("127.0.0.1", port) + res = http.start { |http| http.request(req) } + rescue EOFError, Errno::EPIPE + end + } + sock = serv.accept + begin + assert_match(/chunked/, sock.gets("\r\n\r\n")) + chunk_header = sock.gets.chomp + assert_equal(16 * 1024, chunk_header.to_i(16)) + ensure + sock.close + end + } + ensure + t.join if t + end +end -- cgit v1.2.3