Skip to content

Commit 2a97041

Browse files
JonathanHuotdenji
authored andcommitted
Read the entire HTTP header instead of closing connection after HTTP status line.
1 parent 1407849 commit 2a97041

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

ngx_http_upstream_check_module.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,8 @@ ngx_http_upstream_check_parse_status_line(ngx_http_upstream_check_ctx_t *ctx,
22172217
sw_status,
22182218
sw_space_after_status,
22192219
sw_status_text,
2220+
sw_lf,
2221+
sw_cr,
22202222
sw_almost_done
22212223
} state;
22222224

@@ -2354,20 +2356,43 @@ ngx_http_upstream_check_parse_status_line(ngx_http_upstream_check_ctx_t *ctx,
23542356
case sw_status_text:
23552357
switch (ch) {
23562358
case CR:
2357-
state = sw_almost_done;
2358-
2359+
state = sw_lf;
23592360
break;
23602361
case LF:
23612362
goto done;
23622363
}
23632364
break;
23642365

2365-
/* end of status line */
2366+
/* LF */
2367+
case sw_lf:
2368+
switch (ch) {
2369+
case LF:
2370+
state = sw_cr;
2371+
break;
2372+
default:
2373+
return NGX_ERROR;
2374+
}
2375+
break;
2376+
2377+
/* CR */
2378+
case sw_cr:
2379+
switch (ch) {
2380+
case CR:
2381+
state = sw_almost_done;
2382+
break;
2383+
default:
2384+
state = sw_status_text;
2385+
break;
2386+
}
2387+
break;
2388+
2389+
/* LF */
23662390
case sw_almost_done:
2367-
status->end = p - 1;
2368-
if (ch == LF) {
2391+
switch (ch) {
2392+
case LF:
2393+
status->end = p - 1;
23692394
goto done;
2370-
} else {
2395+
default:
23712396
return NGX_ERROR;
23722397
}
23732398
}

0 commit comments

Comments
 (0)