diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-11-27 16:25:51 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-11-27 16:25:51 +0000 |
commit | d33b112de139cdaffd3f35d8e5b71b6fabd00b71 (patch) | |
tree | 7dce0c3987070c71ee6acd7127ebc463be287b60 /usr.sbin | |
parent | ead35ae95d4fd007e092cb9ab70426f068b7a8be (diff) |
rfc 7230 mandates that a "204 No Content" http status must not come with a
Content-Lenght Header. Of course some servers still so it and send
Content-Lenght: 0. Adjust accordingly.
ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/relayd/relay_http.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index 847737de47b..cf493f8c887 100644 --- a/usr.sbin/relayd/relay_http.c +++ b/usr.sbin/relayd/relay_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_http.c,v 1.69 2017/11/27 03:19:58 claudio Exp $ */ +/* $OpenBSD: relay_http.c,v 1.70 2017/11/27 16:25:50 benno Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -328,19 +328,6 @@ relay_read_http(struct bufferevent *bev, void *arg) goto abort; } /* - * response with a status code of 1xx - * (Informational) or 204 (No Content) MUST - * not have a Content-Length (rfc 7230 3.3.3) - */ - if (desc->http_method == HTTP_METHOD_RESPONSE && ( - ((desc->http_status >= 100 && - desc->http_status < 200) || - desc->http_status == 204))) { - relay_abort_http(con, 500, - "Internal Server Error", 0); - goto abort; - } - /* * Need to read data from the client after the * HTTP header. * XXX What about non-standard clients not using @@ -352,6 +339,23 @@ relay_read_http(struct bufferevent *bev, void *arg) relay_abort_http(con, 500, errstr, 0); goto abort; } + /* + * response with a status code of 1xx + * (Informational) or 204 (No Content) MUST + * not have a Content-Length (rfc 7230 3.3.3) + * Instead we check for value != 0 because there are + * servers that do not follow the rfc and send + * Content-Length: 0. + */ + if (desc->http_method == HTTP_METHOD_RESPONSE && ( + ((desc->http_status >= 100 && + desc->http_status < 200) || + desc->http_status == 204)) && + cre->toread != 0) { + relay_abort_http(con, 502, + "Bad Gateway", 0); + goto abort; + } } lookup: if (strcasecmp("Transfer-Encoding", key) == 0 && |