Skip to content Skip to sidebar Skip to footer

Implementing Handshake For Hybi-17

I'm trying to develop the handshake for websocket hybi-17 protocol (https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-17). According to that draft, I made

Solution 1:

A HTTP response is defined as:

   Response      = Status-Line               ; Section 6.1
                   *(( general-header        ; Section 4.5
                    | response-header        ; Section 6.2
                    | entity-header ) CRLF)  ; Section 7.1
                   CRLF
                   [ message-body ]          ; Section 7.2

The message body is empty, but there should still be two CRLFs after all headers (one CRLF after each header and one final extra one).

So your code should look like:

$value="HTTP/1.1 101 Switching Protocols\r\n" .
  "Upgrade: websocket\r\n" .
  "Connection: Upgrade\r\n" .
  "Sec-WebSocket-Accept: {$key}\r\n\r\n";

Post a Comment for "Implementing Handshake For Hybi-17"