Skip to content

Commit 7e22dd4

Browse files
rlubosnashif
authored andcommitted
net: lib: http_server: Fix frame printouts
Frame printouts should not be done from the state handlers, but rather during state transition, otherwise a single frame can be printed several times as new data arrive. This also simplifies code a bit, as we just print the frame in a single place, instead of duplicating code. Signed-off-by: Robert Lubos <[email protected]>
1 parent 78c2f48 commit 7e22dd4

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

subsys/net/lib/http/http_server_http2.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ int handle_http_frame_header(struct http_client_ctx *client)
729729
client->cursor += bytes_consumed;
730730
client->data_len -= bytes_consumed;
731731

732+
print_http_frames(client);
733+
732734
switch (client->current_frame.type) {
733735
case HTTP2_DATA_FRAME:
734736
return enter_http_frame_data_state(client);
@@ -912,8 +914,6 @@ int handle_http_frame_data(struct http_client_ctx *client)
912914

913915
LOG_DBG("HTTP_SERVER_FRAME_DATA_STATE");
914916

915-
print_http_frames(client);
916-
917917
if (client->current_detail == NULL) {
918918
/* There is no handler */
919919
LOG_DBG("No dynamic handler found.");
@@ -1040,8 +1040,6 @@ int handle_http_frame_headers(struct http_client_ctx *client)
10401040

10411041
LOG_DBG("HTTP_SERVER_FRAME_HEADERS");
10421042

1043-
print_http_frames(client);
1044-
10451043
if (is_header_flag_set(frame->flags, HTTP2_FLAG_PADDED)) {
10461044
ret = parse_http_frame_padded_field(client);
10471045
if (ret < 0) {
@@ -1139,8 +1137,6 @@ int handle_http_frame_priority(struct http_client_ctx *client)
11391137

11401138
LOG_DBG("HTTP_SERVER_FRAME_PRIORITY_STATE");
11411139

1142-
print_http_frames(client);
1143-
11441140
if (frame->length != HTTP2_PRIORITY_FRAME_LEN) {
11451141
return -EBADMSG;
11461142
}
@@ -1168,8 +1164,6 @@ int handle_http_frame_rst_stream(struct http_client_ctx *client)
11681164

11691165
LOG_DBG("FRAME_RST_STREAM");
11701166

1171-
print_http_frames(client);
1172-
11731167
if (frame->length != HTTP2_RST_STREAM_FRAME_LEN) {
11741168
return -EBADMSG;
11751169
}
@@ -1209,8 +1203,6 @@ int handle_http_frame_settings(struct http_client_ctx *client)
12091203

12101204
LOG_DBG("HTTP_SERVER_FRAME_SETTINGS");
12111205

1212-
print_http_frames(client);
1213-
12141206
if (client->data_len < frame->length) {
12151207
return -EAGAIN;
12161208
}
@@ -1241,8 +1233,6 @@ int handle_http_frame_goaway(struct http_client_ctx *client)
12411233

12421234
LOG_DBG("HTTP_SERVER_FRAME_GOAWAY");
12431235

1244-
print_http_frames(client);
1245-
12461236
if (client->data_len < frame->length) {
12471237
return -EAGAIN;
12481238
}
@@ -1263,8 +1253,6 @@ int handle_http_frame_window_update(struct http_client_ctx *client)
12631253

12641254
LOG_DBG("HTTP_SERVER_FRAME_WINDOW_UPDATE");
12651255

1266-
print_http_frames(client);
1267-
12681256
/* TODO Implement flow control, for now just ignore. */
12691257

12701258
if (client->data_len < frame->length) {

0 commit comments

Comments
 (0)