From: Christopher Zimmermann Subject: relayd: Keep Content-Length in response to HEAD request To: millert@openbsd.org, tech@openbsd.org Date: Sat, 29 Jun 2024 19:16:36 +0200 Hi, responses to HEAD requests SHOULD return the same headers a GET request would yield (https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.2). Therefore the Content-Length header should not be stripped from responses to HEAD requests. This bit me when relaying traffic between restic and a restic-rest-server. Restic gets confused by the missing Content-Length: header and complains about a "negative content length" when checking for the presence of /config. OK? Christopher Index: relay_http.c =================================================================== RCS file: /cvs/src/usr.sbin/relayd/relay_http.c,v retrieving revision 1.87 diff -u -p -r1.87 relay_http.c --- relay_http.c 1 Dec 2023 16:48:40 -0000 1.87 +++ relay_http.c 29 Jun 2024 17:02:44 -0000 @@ -435,18 +435,6 @@ relay_read_http(struct bufferevent *bev, kv_delete(&desc->http_headers, desc->http_lastheader); break; - case HTTP_METHOD_RESPONSE: - /* - * Strip Content-Length header from - * HEAD responses since there is no - * actual payload in the response. - */ - if (request_method == HTTP_METHOD_HEAD) { - kv_delete(&desc->http_headers, - desc->http_lastheader); - break; - } - /* FALLTHROUGH */ default: /* * Need to read data from the client