Feature #14237
closed[PATCH 0/2] webrick: use IO.copy_stream
Description
First patch is prepatory, second patch uses IO.copy_stream:
https://80x24.org/spew/20171226043936.7694-1-e@80x24.org/raw
https://80x24.org/spew/20171226043936.7694-2-e@80x24.org/raw
It should support Content-Range in a 3rd (to-be-written) patch,
too.
[PATCH 2/2] webrick/httpresponse: IO.copy_stream for regular files
Remove the redundant _send_file method since its functionality
is unnecessary with IO.copy_stream. IO.copy_stream also allows
the use of sendfile under some OSes to speed up copies to
non-TLS sockets.
Testing with "curl >/dev/null" and "ruby -run -e httpd" to
read a 1G file over Linux loopback reveals a reduction from
around ~0.770 to ~0.490 seconds on the client side.
- lib/webrick/httpresponse.rb (send_body_io): use IO.copy_stream
(_send_file): remove
[PATCH 1/2] webrick: favor .write over << method
This will make the next change to use IO.copy_stream
easier-to-read. When we can drop Ruby 2.4 support in a few
years, this will allow us to use writev(2) with multiple
arguments for headers and chunked responses.
- lib/webrick/cgi.rb (write): new wrapper method
lib/webrick/httpresponse.rb (_write_data): remove
(send_header): use socket.write
(send_body_io): ditto
(send_body_string): ditto
(send_body_proc): ditto
(ChunkedWrapper#write): ditto
(_send_file): ditto
Updated by Anonymous over 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62954.
webrick/httpresponse: IO.copy_stream for regular files
Remove the redundant _send_file method since its functionality
is unnecessary with IO.copy_stream. IO.copy_stream also allows
the use of sendfile under some OSes to speed up copies to
non-TLS sockets.
Testing with "curl >/dev/null" and "ruby -run -e httpd" to
read a 1G file over Linux loopback reveals a reduction from
around ~0.770 to ~0.490 seconds on the client side.
- lib/webrick/httpresponse.rb (send_body_io): use IO.copy_stream
(_send_file): remove
[Feature #14237]