EarthScope / ringserver

Apache License 2.0
30 stars 16 forks source link

upgrade in http.c protocol in print out of order #20

Closed crotwell closed 5 years ago

crotwell commented 5 years ago

in http.c about line 1771, the subprotocolheader is the 2nd arg, but I think belongs with the 3rd %s. Firefox is ok with it currently (ignores the subprotocol I think), but chrome complains with:

during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received

So change:

/* Generate response completing the upgrade to WebSocket connection */
  asprintf (&response,
            "HTTP/1.1 101 Switching Protocols\r\n"
            "Upgrade: websocket\r\n"
            "Connection: Upgrade\r\n"
            "%s"
            "%s"
            "Sec-WebSocket-Accept: %s\r\n"
            "\r\n",
            (cinfo->httpheaders) ? cinfo->httpheaders : "",
            subprotocolheader,
            keybuf);

To:

/* Generate response completing the upgrade to WebSocket connection */
  asprintf (&response,
            "HTTP/1.1 101 Switching Protocols\r\n"
            "Upgrade: websocket\r\n"
            "Connection: Upgrade\r\n"
            "%s"
            "Sec-WebSocket-Accept: %s\r\n"
            "%s"
            "\r\n",
            (cinfo->httpheaders) ? cinfo->httpheaders : "",
            subprotocolheader,
            keybuf);
crotwell commented 5 years ago

Never mind, was bug on the client side, was sending wrong subprotocol string