ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:84456] [Ruby trunk Feature#14237] [PATCH 0/2] webrick: use IO.copy_stream
       [not found] <redmine.issue-14237.20171226062946@ruby-lang.org>
@ 2017-12-26  6:29 ` normalperson
  0 siblings, 0 replies; only message in thread
From: normalperson @ 2017-12-26  6:29 UTC (permalink / raw
  To: ruby-core

Issue #14237 has been reported by normalperson (Eric Wong).

----------------------------------------
Feature #14237: [PATCH 0/2] webrick: use IO.copy_stream
https://bugs.ruby-lang.org/issues/14237

* Author: normalperson (Eric Wong)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-26  6:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-14237.20171226062946@ruby-lang.org>
2017-12-26  6:29 ` [ruby-core:84456] [Ruby trunk Feature#14237] [PATCH 0/2] webrick: use IO.copy_stream normalperson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).