Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
* Websocket Handshake 76
@ 2010-07-07 15:26 Niklas Hofer
  2010-07-07 20:38 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Niklas Hofer @ 2010-07-07 15:26 UTC (permalink / raw)
  To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

Hey

 I just tried to implement the new Websocket Handshake [1] into
Rainbows/Sunshowers. I think I almost succeeded (tests and chrome
passing), but I had to hack something and I want your opinion over it:

 In order to complete the new handshake, the server must use 8 bytes
from the incoming body. Because Rainbows uses the HTTPParser and
checking for the "Content-Length" field and the HTTP-like Websocket
request does not supply such a field, no body is forwarded to the
underlying app stack. (0.94.0: lib/rainbows/base.rb:72).

My suggestion: Set an unused key in the env, for example 'hack.buf' and
use this in lib/sunshowers/websocket.rb.

Is this the right way (TM)?
May there be a better name for the env key?

with regards,
Niklas

[1]
http://axod.blogspot.com/2010/06/websocket-gets-update-and-it-breaks.html
-- 

 _ o                         o    |    o       >    =            o)
  /\    - =   <             (|/   |   \|)               \       (| 
 | \                        /)    |    (\          \  _ /       / \
 
The game of life is a game of boomerangs.  Our thoughts, deeds and words
return to us sooner or later with astounding accuracy.

_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


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

* Re: Websocket Handshake 76
  2010-07-07 15:26 Websocket Handshake 76 Niklas Hofer
@ 2010-07-07 20:38 ` Eric Wong
       [not found]   ` <20100707203848.GA21844-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2010-07-07 20:38 UTC (permalink / raw)
  To: Rainbows! list

Niklas Hofer <niklas+rainbows-75qsND6Xt1xd/oRx+cCnAQ@public.gmane.org> wrote:
> Hey
> 
>  I just tried to implement the new Websocket Handshake [1] into
> Rainbows/Sunshowers. I think I almost succeeded (tests and chrome
> passing), but I had to hack something and I want your opinion over it:
> 
>  In order to complete the new handshake, the server must use 8 bytes
> from the incoming body. Because Rainbows uses the HTTPParser and
> checking for the "Content-Length" field and the HTTP-like Websocket
> request does not supply such a field, no body is forwarded to the
> underlying app stack. (0.94.0: lib/rainbows/base.rb:72).
> 
> My suggestion: Set an unused key in the env, for example 'hack.buf' and
> use this in lib/sunshowers/websocket.rb.
> 
> Is this the right way (TM)?
> May there be a better name for the env key?

Hi Niklas,

I haven't gotten a chance to look into the new WebSocket updates, but
can't you just read the 8 bytes off env["rack.input"]?

  env["rack.input"].read(8)

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


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

* Re: Websocket Handshake 76
       [not found]   ` <20100707203848.GA21844-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2010-07-08 14:41     ` Niklas Hofer
  2010-07-08 20:57       ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Niklas Hofer @ 2010-07-08 14:41 UTC (permalink / raw)
  To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

Am Wed, 7 Jul 2010 13:38:49 -0700
schrieb Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>:

> I haven't gotten a chance to look into the new WebSocket updates, but
> can't you just read the 8 bytes off env["rack.input"]?
> 
>   env["rack.input"].read(8)
> 

I tried that without success, it does not give me anything (seems to
be empty), even if I rewind it beforehand.

Niklas
-- 

 _ o                         o    |    o       >    =            o)
  /\    - =   <             (|/   |   \|)               \       (| 
 | \                        /)    |    (\          \  _ /       / \
 
The game of life is a game of boomerangs.  Our thoughts, deeds and words
return to us sooner or later with astounding accuracy.

_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


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

* Re: Websocket Handshake 76
  2010-07-08 14:41     ` Niklas Hofer
@ 2010-07-08 20:57       ` Eric Wong
       [not found]         ` <20100708205743.GB2991-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2010-07-08 20:57 UTC (permalink / raw)
  To: Rainbows! list

Niklas Hofer <niklas+rainbows-75qsND6Xt1xd/oRx+cCnAQ@public.gmane.org> wrote:
> Am Wed, 7 Jul 2010 13:38:49 -0700
> schrieb Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>:
> 
> > I haven't gotten a chance to look into the new WebSocket updates, but
> > can't you just read the 8 bytes off env["rack.input"]?
> > 
> >   env["rack.input"].read(8)
> > 
> 
> I tried that without success, it does not give me anything (seems to
> be empty), even if I rewind it beforehand.

Ah, apparently -76 doesn't send Content-Length and that
screws things up (UGH!)

'env["hack.io"].read(8)' has a _chance_ of working if the
client delays sending the 8 bytes.

I think I'll need to change Rainbows! to not use readpartial and use
recv_nonblock with MSG_PEEK instead...

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


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

* Re: Websocket Handshake 76
       [not found]         ` <20100708205743.GB2991-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2010-07-08 22:07           ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2010-07-08 22:07 UTC (permalink / raw)
  To: Rainbows! list

Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org> wrote:
> I think I'll need to change Rainbows! to not use readpartial and use
> recv_nonblock with MSG_PEEK instead...

It's too much trouble (and would hurt performance for non-WebSockets
stuff a bit).

Since we're not the only ones experiencing the issue, I think
we should wait until the next specification release and hope
they can fix things for us:

http://www.ietf.org/mail-archive/web/hybi/current/msg02149.html

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


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

end of thread, other threads:[~2010-07-08 22:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07 15:26 Websocket Handshake 76 Niklas Hofer
2010-07-07 20:38 ` Eric Wong
     [not found]   ` <20100707203848.GA21844-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2010-07-08 14:41     ` Niklas Hofer
2010-07-08 20:57       ` Eric Wong
     [not found]         ` <20100708205743.GB2991-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2010-07-08 22:07           ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/rainbows.git/

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