diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-18 13:42:52 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-18 13:42:52 +0000 |
commit | 9a012539baf79006b2c6b25b4eaf8d2cdd40e123 (patch) | |
tree | 0b8f535b800ed312033ff5db7e6ac45415ea15fd /lib/webrick/httpresponse.rb | |
parent | 9e365254a64be2e1eff5ac5aa57ebe72b31ecc51 (diff) | |
download | ruby-9a012539baf79006b2c6b25b4eaf8d2cdd40e123.tar.gz |
* lib/webrick/config.rb (WEBrick::Config::HTTP): add new parameters,
:InputBufferSize and :OutputBufferSize.
* lib/webrick/utils.rb (WEBrick::Utils.timeout): add new timeout
method. this implementation is expected to be compatible with
timeout.rb and faster than timeout.rb.
* lib/webrick/httprequest.rb (WEBrick::HTTPRequest#_read_data):
Timeout.timeout is replaced by WEBrick::Utils.timeout.
* lib/webrick/httprequest.rb: WEBrick::HTTPRequest::BUFSIZE is
replaced by config[:InputBufferSize].
* lib/webrick/httpresposne.rb: WEBrick::HTTPResponse::BUFSIZE is
replaced by config[:OutputBufferSize].
* lib/webrick/server.rb: get rid of unnecessary require.
* test/webrick/test_utils.rb: test for WEBrick::Utils.timeout.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpresponse.rb')
-rw-r--r-- | lib/webrick/httpresponse.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index d0f232d1e1..b3f1abef88 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -16,8 +16,6 @@ require 'webrick/httpstatus' module WEBrick class HTTPResponse - BUFSIZE = 1024*4 - attr_reader :http_version, :status, :header attr_reader :cookies attr_accessor :reason_phrase @@ -30,6 +28,7 @@ module WEBrick def initialize(config) @config = config + @buffer_size = config[:OutputBufferSize] @logger = config[:Logger] @header = Hash.new @status = HTTPStatus::RC_OK @@ -258,7 +257,7 @@ module WEBrick if @request_method == "HEAD" # do nothing elsif chunked? - while buf = @body.read(BUFSIZE) + while buf = @body.read(@buffer_size) next if buf.empty? data = "" data << format("%x", buf.size) << CRLF @@ -282,7 +281,7 @@ module WEBrick # do nothing elsif chunked? remain = body ? @body.size : 0 - while buf = @body[@sent_size, BUFSIZE] + while buf = @body[@sent_size, @buffer_size] break if buf.empty? data = "" data << format("%x", buf.size) << CRLF @@ -301,18 +300,18 @@ module WEBrick def _send_file(output, input, offset, size) while offset > 0 - sz = BUFSIZE < offset ? BUFSIZE : offset + sz = @buffer_size < size ? @buffer_size : size buf = input.read(sz) offset -= buf.size end if size == 0 - while buf = input.read(BUFSIZE) + while buf = input.read(@buffer_size) _write_data(output, buf) end else while size > 0 - sz = BUFSIZE < size ? BUFSIZE : size + sz = @buffer_size < size ? @buffer_size : size buf = input.read(sz) _write_data(output, buf) size -= buf.size |