diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-02-06 18:28:40 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-02-06 18:28:40 +0100 |
commit | a785dc96708d8edb5f2ae786a8deee7798523762 (patch) | |
tree | 5400c4297d7879f54b72f6ae730025a504083e73 | |
parent | 2b7d4554717a282d1e78a72dab6aa8e924b37b86 (diff) | |
download | json-rpc-shell-a785dc96708d8edb5f2ae786a8deee7798523762.tar.gz json-rpc-shell-a785dc96708d8edb5f2ae786a8deee7798523762.tar.xz json-rpc-shell-a785dc96708d8edb5f2ae786a8deee7798523762.zip |
WebSocket: fix header parsing
-rw-r--r-- | demo-json-rpc-server.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index a528b60..b2d804d 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -476,7 +476,7 @@ struct ws_handler // HTTP 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 @@ -873,14 +873,14 @@ static int ws_handler_on_header_field (http_parser *parser, const char *at, size_t len) { struct ws_handler *self = parser->data; - if (self->parsing_header_value) + if (self->have_header_value) { ws_handler_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; } @@ -889,13 +889,17 @@ ws_handler_on_header_value (http_parser *parser, const char *at, size_t len) { struct ws_handler *self = parser->data; str_append_data (&self->value, at, len); - self->parsing_header_value = true; + self->have_header_value = true; return 0; } static int ws_handler_on_headers_complete (http_parser *parser) { + struct ws_handler *self = parser->data; + if (self->have_header_value) + ws_handler_on_header_read (self); + // We strictly require a protocol upgrade if (!parser->upgrade) return 2; |