summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 19:00:48 +0000
committerwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 19:00:48 +0000
commit70271340af90bdfedd52854b45704cb488946d92 (patch)
treebfbacc2fb9c4dfa20cc36cdb83cbdaf5e21db217 /test
parent1e86a6b9ca71dbf12cab2795410a0ca3f0cd5b3a (diff)
lib/net/http.rb: Backport #1284 [ruby-core:22874]; Change Net:HTTP to use a block size of 16k instead of 1k when streaming or chunking POST bodies.
test/net/http/test_post_io.rb: Backport #1284 [ruby-core:22874]; A test to go with the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@28198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/http/test_post_io.rb32
1 files changed, 32 insertions, 0 deletions
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