Skip to content

Commit

Permalink
io: use case insensitive check for Connection & Upgrade websock headers
Browse files Browse the repository at this point in the history
When checking the value of the Connection and Upgrade HTTP headers
the websock RFC (6455) requires the comparison to be case insensitive.
The Connection value should be an exact match not a substring.

Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Daniel P. Berrange <[email protected]>
  • Loading branch information
berrange committed Oct 4, 2017
1 parent 3a3f870 commit 33badfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions io/channel-websock.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
goto bad_request;
}

if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) {
if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) {
error_setg(errp, "No connection upgrade requested '%s'", connection);
goto bad_request;
}

if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) {
if (strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) {
error_setg(errp, "Incorrect upgrade method '%s'", upgrade);
goto bad_request;
}
Expand Down

0 comments on commit 33badfd

Please sign in to comment.