aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-02-06 18:27:40 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-02-06 18:27:40 +0100
commitd73aa0436c9347330424031d039fdbe05fb3ec63 (patch)
tree814e9e9f38968a1b3058a724671cc39dda97fef1
parent58408ae74ada42e142df53bd8ea084deeb106ca2 (diff)
downloadjson-rpc-shell-d73aa0436c9347330424031d039fdbe05fb3ec63.tar.gz
json-rpc-shell-d73aa0436c9347330424031d039fdbe05fb3ec63.tar.xz
json-rpc-shell-d73aa0436c9347330424031d039fdbe05fb3ec63.zip
WebSocket: fix header parsing
-rw-r--r--json-rpc-shell.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 2a36bf8..6792bb4 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -1302,7 +1302,7 @@ struct ws_context
char *key; ///< Key for the current handshake
http_parser hp; ///< HTTP parser
- bool parsing_header_value; ///< Parsing header value or field?
+ bool have_header_value; ///< Parsing header value or field?
struct str field; ///< Field part buffer
struct str value; ///< Value part buffer
struct str_map headers; ///< HTTP Headers
@@ -1431,14 +1431,14 @@ static int
backend_ws_on_header_field (http_parser *parser, const char *at, size_t len)
{
struct ws_context *self = parser->data;
- if (self->parsing_header_value)
+ if (self->have_header_value)
{
backend_ws_on_header_read (self);
str_reset (&self->field);
str_reset (&self->value);
}
str_append_data (&self->field, at, len);
- self->parsing_header_value = false;
+ self->have_header_value = false;
return 0;
}
@@ -1447,13 +1447,17 @@ backend_ws_on_header_value (http_parser *parser, const char *at, size_t len)
{
struct ws_context *self = parser->data;
str_append_data (&self->value, at, len);
- self->parsing_header_value = true;
+ self->have_header_value = true;
return 0;
}
static int
backend_ws_on_headers_complete (http_parser *parser)
{
+ struct ws_context *self = parser->data;
+ if (self->have_header_value)
+ backend_ws_on_header_read (self);
+
// We strictly require a protocol upgrade
if (!parser->upgrade)
return 2;