Skip to content

Commit

Permalink
http2: flatten code style
Browse files Browse the repository at this point in the history
(cherry picked from commit 42ba421)
  • Loading branch information
catenacyber authored and victorjulien committed Oct 5, 2021
1 parent 69a70de commit 0c49232
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/app-layer-htp.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,23 +960,25 @@ static AppLayerResult HTPHandleResponseData(Flow *f, void *htp_state,
if (tx != NULL && tx->response_status_number == 101) {
htp_header_t *h =
(htp_header_t *)htp_table_get_c(tx->response_headers, "Upgrade");
if (h != NULL) {
if (bstr_cmp_c(h->value, "h2c") == 0) {
uint16_t dp = 0;
if (tx->request_port_number != -1) {
dp = (uint16_t)tx->request_port_number;
}
consumed = htp_connp_res_data_consumed(hstate->connp);
AppLayerRequestProtocolChange(hstate->f, dp, ALPROTO_HTTP2);
// During HTTP2 upgrade, we may consume the HTTP1 part of the data
// and we need to parser the remaining part with HTTP2
if (consumed > 0 && consumed < input_len) {
SCReturnStruct(
APP_LAYER_INCOMPLETE(consumed, input_len - consumed));
}
SCReturnStruct(APP_LAYER_OK);
}
if (h == NULL) {
break;
}
if (bstr_cmp_c(h->value, "h2c") != 0) {
break;
}
uint16_t dp = 0;
if (tx->request_port_number != -1) {
dp = (uint16_t)tx->request_port_number;
}
consumed = htp_connp_res_data_consumed(hstate->connp);
AppLayerRequestProtocolChange(hstate->f, dp, ALPROTO_HTTP2);
// During HTTP2 upgrade, we may consume the HTTP1 part of the data
// and we need to parser the remaining part with HTTP2
if (consumed > 0 && consumed < input_len) {
SCReturnStruct(
APP_LAYER_INCOMPLETE(consumed, input_len - consumed));
}
SCReturnStruct(APP_LAYER_OK);
}
break;
default:
Expand Down

0 comments on commit 0c49232

Please sign in to comment.