From: Yehuda Katz Date: 2011-07-18T16:30:20+09:00 Subject: [ruby-core:38161] Re: Proposal to merge net2-http for Ruby 1.9.4 --20cf307f378278b11d04a852f81f Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Yehuda Katz Chief Technologist | Strobe (ph) 718.877.1325 On Mon, Jul 18, 2011 at 4:19 PM, Clifford Heath w= rote: > Awesome stuff, Yehuda! I look forward to this making its way into a > distribution. > > On 18/07/2011, at 4:44 PM, Yehuda Katz wrote: > >> =95 It is possible to read_nonblock from Net::HTTP response, even= if >> the response has Transfer-Encoding: Chunked, keepalive or compression. T= his >> makes it possible to use Net::HTTP in reactor libraries, instead of writ= ing >> whole new HTTP libraries for each kind of reactor >> > > Does this also work with SSL? > Yes, assuming that the SSLSocket is, in fact, as polymorphic with Socket as it claims to be. > I recall seeing tweets from you questioning why reading from an SSL socke= t > might be affected by whether the socket is currently writable - I assume > you > worked out that it's due to handshaking (which can be re-initiated at any > point > during an SSL connection). Even though the application layer is in a mode > where it expects only to read, the handshake may require writing, and hen= ce > can block on write if the socket is currently stalled. > Yep! I worked it out. Thanks for the full explanation :) > =95 Make the body parsers (regular body and chunked encoding) >> separate objects that can support either blocking read or non-blocking r= ead. >> > > Heh. Now all we need is a revision of the Rack API to allow reading chunk= ed > bodies in a piecemeal fashion. They can already be sent, because the > response body may be enumerable - though that's still not reactor-friendl= y. > > I use async_sinatra which hacks Thin to make the EventMachine reactor > work correctly - see http://github.com/raggi's projects. > > Integration to support websockets is also high on the list of wants. You > should > ask on > > how best to do that, since many > of the interested parties hang out there. > > =95 Improving the tests to test non-blocking read across all kind= s of >> requests, and add tests for decompression >> > > I'd be interested in how you test non-blocking for SSL connections, seein= g > as > you need a custom SSL server which triggers renewed handshakes to do it > properly...? > I'm currently simply using the tests that shipped with Net::HTTP in the current stdlib, but I'd be very interested in ways to improve them. Unfortunately, the current SSL tests are not as exhaustive as the other tests (such as the ones that test gzip or Transfer-Encoding: chunked), but = I would like to improve that. > > Clifford Heath, Data Constellation, http://dataconstellation.com > Agile Information Management and Design > Skype: cjheath, Ph: (+61/0)401-533-540 > > > > --20cf307f378278b11d04a852f81f Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
Yehuda Katz
Chief Technologist | Strobe
(ph) 718.87= 7.1325


On Mon, Jul 18, 2011 at 4:19 PM, Cliffor= d Heath <c= lifford.heath@gmail.com> wrote:
Awesome stuff, Yehuda! I look forward to this making its way into a distrib= ution.

On 18/07/2011, at 4:44 PM, Yehuda Katz wrote:
=A0 =A0 =A0 =A0=95 It is possible to read_nonblock from Net::HTTP response= , even if the response has Transfer-Encoding: Chunked, keepalive or compres= sion. This makes it possible to use Net::HTTP in reactor libraries, instead= of writing whole new HTTP libraries for each kind of reactor

Does this also work with SSL?

Yes, assu= ming that the SSLSocket is, in fact, as polymorphic with Socket as it claim= s to be.
=A0
I recall seeing tweets from you questioning why reading from an SSL socket<= br> might be affected by whether the socket is currently writable - I assume yo= u
worked out that it's due to handshaking (which can be re-initiated at a= ny point
during an SSL connection). Even though the application layer is in a mode where it expects only to read, the handshake may require writing, and hence=
can block on write if the socket is currently stalled.

Yep! I worked it out. Thanks for the full explanation :)
=A0
=A0 =A0 =A0 =A0=95 Make the body parsers (regular body and chunked encodin= g) separate objects that can support either blocking read or non-blocking r= ead.

Heh. Now all we need is a revision of the Rack API to allow reading chunked=
bodies in a piecemeal fashion. They can already be sent, because the
response body may be enumerable - though that's still not reactor-frien= dly.

I use async_sinatra which hacks Thin to make the EventMachine reactor
work correctly - see http://github.com/raggi's projects.

Integration to support websockets is also high on the list of wants. You sh= ould
ask on <mailto:socket_io@googlegroups.com> how best to do that, since= many
of the interested parties hang out there.

=A0 =A0 =A0 =A0=95 Improving the tests to test non-blocking read across al= l kinds of requests, and add tests for decompression

I'd be interested in how you test non-blocking for SSL connections, see= ing as
you need a custom SSL server which triggers renewed handshakes to do it
properly...?

I'm currently simply u= sing the tests that shipped with Net::HTTP in the current stdlib, but I'= ;d be very interested in ways to improve them. Unfortunately, the current S= SL tests are not as exhaustive as the other tests (such as the ones that te= st gzip or Transfer-Encoding: chunked), but I would like to improve that.
=A0

Clifford Heath, Data Constellation, http://dataconstellation.com
Agile Information Management and Design
Skype: cjheath, Ph: (+61/0)401-533-540




--20cf307f378278b11d04a852f81f--