ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:69604] [Ruby trunk - Feature #11266] [Open] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
@ 2015-06-16  9:35 ` me
  2015-06-16 12:48 ` [ruby-core:69607] [Ruby trunk - Feature #11266] " me
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-06-16  9:35 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been reported by Julik Tarkhanov.

----------------------------------------
Feature #11266: WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69607] [Ruby trunk - Feature #11266] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
  2015-06-16  9:35 ` [ruby-core:69604] [Ruby trunk - Feature #11266] [Open] WEBrick: allow subclassing of Response and Request me
@ 2015-06-16 12:48 ` me
  2015-06-16 13:12 ` [ruby-core:69608] [Ruby trunk - Feature #11266] [PATCH] " me
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-06-16 12:48 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.

File custom_req_response.patch added

Patch against current trunk, should be backportable.

----------------------------------------
Feature #11266: WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-52950

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69608] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
  2015-06-16  9:35 ` [ruby-core:69604] [Ruby trunk - Feature #11266] [Open] WEBrick: allow subclassing of Response and Request me
  2015-06-16 12:48 ` [ruby-core:69607] [Ruby trunk - Feature #11266] " me
@ 2015-06-16 13:12 ` me
  2015-06-17  1:08 ` [ruby-core:69624] " nobu
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-06-16 13:12 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.

Subject changed from WEBrick: allow subclassing of Response and Request to [PATCH] WEBrick: allow subclassing of Response and Request

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-52951

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69624] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-06-16 13:12 ` [ruby-core:69608] [Ruby trunk - Feature #11266] [PATCH] " me
@ 2015-06-17  1:08 ` nobu
  2015-06-17 18:42 ` [ruby-core:69635] " me
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2015-06-17  1:08 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Nobuyoshi Nakada.


Any reason to create both together in `create_request_and_response`?

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-52969

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69635] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-06-17  1:08 ` [ruby-core:69624] " nobu
@ 2015-06-17 18:42 ` me
  2015-06-19  9:39 ` [ruby-core:69679] " me
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-06-17 18:42 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.


No specific reason, only to make the changes to the library smaller. They certainly can be separate methods.

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-52989

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69679] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-06-17 18:42 ` [ruby-core:69635] " me
@ 2015-06-19  9:39 ` me
  2015-07-10 19:14 ` [ruby-core:69944] " me
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-06-19  9:39 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.

File req_response_sub2.patch added

Version with separate methods

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-53048

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69944] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-06-19  9:39 ` [ruby-core:69679] " me
@ 2015-07-10 19:14 ` me
  2015-07-11  0:07 ` [ruby-core:69945] [Ruby trunk - Feature #11266] [Assigned] " nobu
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-07-10 19:14 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.


Nobu, is there something else I can do?

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-53371

* Author: Julik Tarkhanov
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:69945] [Ruby trunk - Feature #11266] [Assigned] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2015-07-10 19:14 ` [ruby-core:69944] " me
@ 2015-07-11  0:07 ` nobu
  2015-08-05 10:43 ` [ruby-core:70249] [Ruby trunk - Feature #11266] " me
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2015-07-11  0:07 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Nobuyoshi Nakada.

Status changed from Open to Assigned
Assignee set to Hiroshi Nakamura

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-53372

* Author: Julik Tarkhanov
* Status: Assigned
* Priority: Normal
* Assignee: Hiroshi Nakamura
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:70249] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2015-07-11  0:07 ` [ruby-core:69945] [Ruby trunk - Feature #11266] [Assigned] " nobu
@ 2015-08-05 10:43 ` me
  2016-06-23 17:47 ` [ruby-core:76121] [Ruby trunk Feature#11266] " me
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2015-08-05 10:43 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.


Is there still anything I can do/change?

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-53672

* Author: Julik Tarkhanov
* Status: Assigned
* Priority: Normal
* Assignee: Hiroshi Nakamura
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:76121] [Ruby trunk Feature#11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2015-08-05 10:43 ` [ruby-core:70249] [Ruby trunk - Feature #11266] " me
@ 2016-06-23 17:47 ` me
  2016-06-30  9:12 ` [ruby-core:76212] " naruse
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: me @ 2016-06-23 17:47 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Julik Tarkhanov.


It has been a year. Is there still anything I can do/change?

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-59325

* Author: Julik Tarkhanov
* Status: Assigned
* Priority: Normal
* Assignee: Hiroshi Nakamura
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:76212] [Ruby trunk Feature#11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2016-06-23 17:47 ` [ruby-core:76121] [Ruby trunk Feature#11266] " me
@ 2016-06-30  9:12 ` naruse
  2016-07-26 13:43 ` [ruby-core:76575] " rr.rosas
  2018-11-20 16:09 ` [ruby-core:89910] " me
  12 siblings, 0 replies; 14+ messages in thread
From: naruse @ 2016-06-30  9:12 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Yui NARUSE.

Assignee changed from Hiroshi Nakamura to webrick

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-59428

* Author: Julik Tarkhanov
* Status: Assigned
* Priority: Normal
* Assignee: webrick
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:76575] [Ruby trunk Feature#11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2016-06-30  9:12 ` [ruby-core:76212] " naruse
@ 2016-07-26 13:43 ` rr.rosas
  2018-11-20 16:09 ` [ruby-core:89910] " me
  12 siblings, 0 replies; 14+ messages in thread
From: rr.rosas @ 2016-07-26 13:43 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by Rodrigo Rosenfeld Rosas.


+1 Since WEBrick is part of stdlib, being able to use it in a generic test server which supported Rack hijack would be great as such requests could be tested without any sort of mocking.

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-59801

* Author: Julik Tarkhanov
* Status: Assigned
* Priority: Normal
* Assignee: webrick
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:89910] [Ruby trunk Feature#11266] [PATCH] WEBrick: allow subclassing of Response and Request
       [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2016-07-26 13:43 ` [ruby-core:76575] " rr.rosas
@ 2018-11-20 16:09 ` me
  2018-12-19 18:31   ` [ruby-core:90621] " Eric Wong
  12 siblings, 1 reply; 14+ messages in thread
From: me @ 2018-11-20 16:09 UTC (permalink / raw)
  To: ruby-core

Issue #11266 has been updated by julik (Julik Tarkhanov).


It has been... a very long time. Nobu, is there something else I can do?

----------------------------------------
Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request
https://bugs.ruby-lang.org/issues/11266#change-74992

* Author: julik (Julik Tarkhanov)
* Status: Assigned
* Priority: Normal
* Assignee: webrick
* Target version: 
----------------------------------------
To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse.

* The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work.
* The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier.
* The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler.

Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.)

Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method.

If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place.

I will be happy to provide a patch.


---Files--------------------------------
custom_req_response.patch (3.25 KB)
req_response_sub2.patch (2.54 KB)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:90621] Re: [Ruby trunk Feature#11266] [PATCH] WEBrick: allow subclassing of Response and Request
  2018-11-20 16:09 ` [ruby-core:89910] " me
@ 2018-12-19 18:31   ` Eric Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Wong @ 2018-12-19 18:31 UTC (permalink / raw)
  To: ruby-core

me@julik.nl wrote:
> It has been... a very long time. Nobu, is there something else I can do?
>
> https://bugs.ruby-lang.org/issues/11266#change-74992

Committed as r66452.  Sorry for the delays, I wasn't webrick
maintainer at the time this was brought up so I missed it.

In the future, ping us every week or so to get more people to notice
it. And feel free to Cc: me on webrick or any changes I've been
responsible for in the past.  Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-12-19 18:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11266.20150616093526@ruby-lang.org>
2015-06-16  9:35 ` [ruby-core:69604] [Ruby trunk - Feature #11266] [Open] WEBrick: allow subclassing of Response and Request me
2015-06-16 12:48 ` [ruby-core:69607] [Ruby trunk - Feature #11266] " me
2015-06-16 13:12 ` [ruby-core:69608] [Ruby trunk - Feature #11266] [PATCH] " me
2015-06-17  1:08 ` [ruby-core:69624] " nobu
2015-06-17 18:42 ` [ruby-core:69635] " me
2015-06-19  9:39 ` [ruby-core:69679] " me
2015-07-10 19:14 ` [ruby-core:69944] " me
2015-07-11  0:07 ` [ruby-core:69945] [Ruby trunk - Feature #11266] [Assigned] " nobu
2015-08-05 10:43 ` [ruby-core:70249] [Ruby trunk - Feature #11266] " me
2016-06-23 17:47 ` [ruby-core:76121] [Ruby trunk Feature#11266] " me
2016-06-30  9:12 ` [ruby-core:76212] " naruse
2016-07-26 13:43 ` [ruby-core:76575] " rr.rosas
2018-11-20 16:09 ` [ruby-core:89910] " me
2018-12-19 18:31   ` [ruby-core:90621] " Eric Wong

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).