summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib/net/http.rb6
-rw-r--r--test/net/http/test_post_io.rb32
-rw-r--r--version.h10
4 files changed, 50 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 5aecf003a2..7522a30a65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Apr 2 03:27:22 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * 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.
+
Thu Apr 1 05:32:17 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* string.c (rb_str_inspect): wrong result of UTF-8 inspect because of
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 869773bc92..59e9c0c7f0 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1467,6 +1467,8 @@ module Net #:nodoc:
include HTTPHeader
+ BUFSIZE = 16*1024
+
def initialize(m, reqbody, resbody, path, initheader = nil)
@method = m
@request_has_body = reqbody
@@ -1552,12 +1554,12 @@ module Net #:nodoc:
supply_default_content_type
write_header sock, ver, path
if chunked?
- while s = f.read(1024)
+ while s = f.read(BUFSIZE)
sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
end
sock.write "0\r\n\r\n"
else
- while s = f.read(1024)
+ while s = f.read(BUFSIZE)
sock.write s
end
end
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
diff --git a/version.h b/version.h
index dbfb7de157..4aa1ad1920 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2010-04-01"
+#define RUBY_RELEASE_DATE "2010-04-02"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20100401
-#define RUBY_PATCHLEVEL 250
+#define RUBY_RELEASE_CODE 20100402
+#define RUBY_PATCHLEVEL 251
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 2
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
@@ -26,4 +26,4 @@ RUBY_EXTERN const char *ruby_copyright;
#define RUBY_BIRTH_DAY 24
#define RUBY_RELEASE_STR "patchlevel"
-#define RUBY_RELEASE_NUM RUBY_PATCHLEVEL
+#define RUBY_RELEASE_NUM RUBY_PATCHLEVEL \ No newline at end of file