Re: Mongrel2 not parsing a websocket header
- From:
- Xavier Lange
- Date:
- 2011-09-25 @ 00:59
Ah, figured it out. Missing a final CLRF necessary to satisfy the parser.
On Sat, Sep 24, 2011 at 2:12 PM, Xavier Lange <xrlange@gmail.com> wrote:
> I'm trying to fuzz my websocket implementation and I can't seem to get
> mongrel2 to parse what I'm feeding it. My handler never gets the
> websocket info. Any ideas?
>
> Here's a simple ruby script to demonstrate:
> handshake = %Q{GET /ws HTTP/1.1\r\nHost: localhost\r\nUpgrade:
> websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key:
> dGhlIHNhbXBsZSBub25jZQ==\r\nSec-WebSocket-Version: 8\r\n}
> TCPSocket.open("localhost",6767) do |sock|
> sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
> sock.puts(handshake)
> sock.flush
>
> msg = sock.recv 100
> puts msg
> end
>
> And here's the (modified) mongrel2 debug message from the io handler,
> stating that it did not get enough info:
> DEBUG src/io.c:489: Socket was closed, will return only what's available: 147,
> GET /ws HTTP/1.1
> Host: localhost
> Upgrade: websocket
> Connection: Upgrade
> Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
> Sec-WebSocket-Version: 8
>
> DEBUG src/connection.c:797: Client closed during read.
>