diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index 45eb63283..f60b2c50b 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -336,9 +336,7 @@ start_ws_handshake: #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) wsi->http.ah->parser_state = WSI_TOKEN_NAME_PART; wsi->http.ah->lextable_pos = 0; -#if defined(LWS_WITH_CUSTOM_HEADERS) wsi->http.ah->unk_pos = 0; -#endif /* If we're (re)starting on hdr, need other implied init */ wsi->http.ah->ues = URIES_IDLE; #endif @@ -370,9 +368,7 @@ client_http_body_sent: /* prepare ourselves to do the parsing */ wsi->http.ah->parser_state = WSI_TOKEN_NAME_PART; wsi->http.ah->lextable_pos = 0; -#if defined(LWS_WITH_CUSTOM_HEADERS) wsi->http.ah->unk_pos = 0; -#endif #endif lwsi_set_state(wsi, LRS_WAITING_SERVER_REPLY); lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, @@ -537,9 +533,7 @@ lws_http_transaction_completed_client(struct lws *wsi) wsi->http.ah->parser_state = WSI_TOKEN_NAME_PART; wsi->http.ah->lextable_pos = 0; -#if defined(LWS_WITH_CUSTOM_HEADERS) wsi->http.ah->unk_pos = 0; -#endif lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, wsi->context->timeout_secs); diff --git a/lib/roles/http/parsers.c b/lib/roles/http/parsers.c index 7abedb6a9..6a9914cec 100644 --- a/lib/roles/http/parsers.c +++ b/lib/roles/http/parsers.c @@ -96,8 +96,8 @@ _lws_header_table_reset(struct allocated_headers *ah) ah->http_response = 0; ah->parser_state = WSI_TOKEN_NAME_PART; ah->lextable_pos = 0; -#if defined(LWS_WITH_CUSTOM_HEADERS) ah->unk_pos = 0; +#if defined(LWS_WITH_CUSTOM_HEADERS) ah->unk_ll_head = 0; ah->unk_ll_tail = 0; #endif @@ -1097,9 +1097,6 @@ swallow: if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; - -#if defined(LWS_WITH_CUSTOM_HEADERS) - /* * ...in case it's an unknown header, speculatively * store it as the name comes in. If we recognize it as @@ -1108,6 +1105,7 @@ swallow: if (!wsi->mux_substream && !ah->unk_pos) { ah->unk_pos = ah->pos; +#if defined(LWS_WITH_CUSTOM_HEADERS) /* * Prepare new unknown header linked-list entry * @@ -1118,8 +1116,8 @@ swallow: for (n = 0; n < 8; n++) if (!lws_pos_in_bounds(wsi)) ah->data[ah->pos++] = 0; - } #endif + } if (lws_pos_in_bounds(wsi)) return LPR_FAIL; @@ -1201,7 +1199,6 @@ nope: /* b7 = 0, end or 3-byte */ if (lextable_h1[pos] < FAIL_CHAR) { -#if defined(LWS_WITH_CUSTOM_HEADERS) if (!wsi->mux_substream) { /* * We hit a terminal marker, so @@ -1212,7 +1209,7 @@ nope: ah->pos = ah->unk_pos; ah->unk_pos = 0; } -#endif + ah->lextable_pos = pos; break; } @@ -1390,10 +1387,7 @@ excessive: goto forbid; if (c == '\x0a') { ah->parser_state = WSI_TOKEN_NAME_PART; -#if defined(LWS_WITH_CUSTOM_HEADERS) - ah->unk_pos = 0; -#endif - ah->lextable_pos = 0; + ah->unk_pos = ah->lextable_pos = 0; } else ah->parser_state = WSI_TOKEN_SKIPPING; break; diff --git a/lib/roles/http/private-lib-roles-http.h b/lib/roles/http/private-lib-roles-http.h index 2bf43fe06..16a8c16d2 100644 --- a/lib/roles/http/private-lib-roles-http.h +++ b/lib/roles/http/private-lib-roles-http.h @@ -125,9 +125,9 @@ struct allocated_headers { ah_data_idx_t pos; ah_data_idx_t http_response; ah_data_idx_t current_token_limit; + ah_data_idx_t unk_pos; /* to undo speculative unknown header */ #if defined(LWS_WITH_CUSTOM_HEADERS) - ah_data_idx_t unk_pos; /* to undo speculative unknown header */ ah_data_idx_t unk_value_pos; ah_data_idx_t unk_ll_head;