@@ -393,7 +393,6 @@ static void generate_accept_string(const std::string& client_key,
393393}
394394
395395static int header_value_cb (http_parser* parser, const char * at, size_t length) {
396- static const char SEC_WEBSOCKET_KEY_HEADER[] = " Sec-WebSocket-Key" ;
397396 auto inspector = static_cast <InspectorSocket*>(parser->data );
398397 auto state = inspector->http_parsing_state ;
399398 state->parsing_value = true ;
@@ -519,7 +518,7 @@ static bool IsAllowedHost(const std::string& host_with_port) {
519518static int message_complete_cb (http_parser* parser) {
520519 InspectorSocket* inspector = static_cast <InspectorSocket*>(parser->data );
521520 struct http_parsing_state_s * state = inspector->http_parsing_state ;
522- state-> ws_key = HeaderValue (state, " Sec-WebSocket-Key" );
521+ std::string ws_key = HeaderValue (state, " Sec-WebSocket-Key" );
523522
524523 if (!IsAllowedHost (HeaderValue (state, " Host" )) ||
525524 parser->method != HTTP_GET) {
@@ -530,12 +529,12 @@ static int message_complete_cb(http_parser* parser) {
530529 } else {
531530 handshake_failed (inspector);
532531 }
533- } else if (state-> ws_key .empty ()) {
532+ } else if (ws_key.empty ()) {
534533 handshake_failed (inspector);
535534 } else if (state->callback (inspector, kInspectorHandshakeUpgrading ,
536535 state->path )) {
537536 char accept_string[ACCEPT_KEY_LENGTH];
538- generate_accept_string (state-> ws_key , &accept_string);
537+ generate_accept_string (ws_key, &accept_string);
539538 const char accept_ws_prefix[] = " HTTP/1.1 101 Switching Protocols\r\n "
540539 " Upgrade: websocket\r\n "
541540 " Connection: Upgrade\r\n "
@@ -589,7 +588,7 @@ static void init_handshake(InspectorSocket* socket) {
589588 http_parsing_state_s* state = socket->http_parsing_state ;
590589 CHECK_NE (state, nullptr );
591590 state->current_header .clear ();
592- state->ws_key .clear ();
591+ state->headers .clear ();
593592 state->path .clear ();
594593 state->done = false ;
595594 http_parser_init (&state->parser , HTTP_REQUEST);
0 commit comments