Skip to content

Commit de0c848

Browse files
Eugene OstroukhovMylesBorins
authored andcommitted
inspector: minor adjustments
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/108 PR-URL: https://github.com/nodejs-private/node-private/pull/102/ Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent b769065 commit de0c848

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/inspector_socket.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ static void generate_accept_string(const std::string& client_key,
393393
}
394394

395395
static 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) {
519518
static 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);

src/inspector_socket.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ struct http_parsing_state_s {
3535
handshake_cb callback;
3636
bool done;
3737
bool parsing_value;
38-
std::string ws_key;
3938
std::string path;
4039
std::string current_header;
4140
std::map<std::string, std::string> headers;

0 commit comments

Comments
 (0)