Welcome! Log In Create A New Profile

Advanced

[PATCH] Ignore unexpected 1xx status messages from the upstream.

Piotr Sikora
December 20, 2012 11:14PM
Ignore unexpected 1xx status messages from the upstream.

RFC2616 10.1 Informational 1xx says:
A client MUST be prepared to accept one or more 1xx status responses
prior to a regular response, even if the client does not expect a 100
(Continue) status message. Unexpected 1xx status responses MAY be
ignored by a user agent.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
---
src/http/ngx_http_parse.c | 71 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 68 insertions(+), 3 deletions(-)

diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index a6ee74e..835edda 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -1432,7 +1432,11 @@
sw_status,
sw_space_after_status,
sw_status_text,
- sw_almost_done
+ sw_almost_done,
+ sw_ignore_space_after_status,
+ sw_ignore_start,
+ sw_ignore_text,
+ sw_ignore_almost_done
} state;

state = r->state;
@@ -1554,8 +1558,17 @@
status->code = status->code * 10 + ch - '0';

if (++status->count == 3) {
- state = sw_space_after_status;
- status->start = p - 2;
+ if (status->code == 100
+ && r->http_major == 1 && r->http_minor == 1)
+ {
+ state = sw_ignore_space_after_status;
+ status->code = 0;
+ status->count = 0;
+
+ } else {
+ state = sw_space_after_status;
+ status->start = p - 2;
+ }
}

break;
@@ -1600,6 +1613,58 @@
default:
return NGX_ERROR;
}
+ break;
+
+ /* space or end of line in ignored part */
+ case sw_ignore_space_after_status:
+ switch (ch) {
+ case ' ':
+ state = sw_ignore_text;
+ break;
+ case CR:
+ state = sw_ignore_text;
+ break;
+ case LF:
+ state = sw_ignore_start;
+ break;
+ default:
+ return NGX_ERROR;
+ }
+ break;
+
+ /* new line in ignored part */
+ case sw_ignore_start:
+ switch (ch) {
+ case CR:
+ state = sw_ignore_almost_done;
+ break;
+ case LF:
+ state = sw_start;
+ break;
+ default:
+ state = sw_ignore_text;
+ break;
+ }
+ break;
+
+ /* any text in ignored part until end of line */
+ case sw_ignore_text:
+ switch (ch) {
+ case LF:
+ state = sw_ignore_start;
+ break;
+ }
+ break;
+
+ /* end of ignored part */
+ case sw_ignore_almost_done:
+ switch (ch) {
+ case LF:
+ state = sw_start;
+ break;
+ default:
+ return NGX_ERROR;
+ }
}
}

--
1.8.0.2

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Ignore unexpected 1xx status messages from the upstream.

Piotr Sikora 982 December 20, 2012 11:14PM

Re: [PATCH] Ignore unexpected 1xx status messages from the upstream.

Maxim Dounin 582 December 21, 2012 09:48AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready