summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/server_http.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2018-06-15 12:36:06 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2018-06-15 12:36:06 +0000
commitb287d6b79c3b47c72dcc5d65b106ae1f7878e443 (patch)
treeb49cd7b746701d5869cac256ca6ee0dc3ff3c9bd /usr.sbin/httpd/server_http.c
parent9e854404ac45f6a17b239720f7cf12df79de20da (diff)
Fix 304 Not Modified response: don't send a body, use the correct MIME type.
Reported by Hidvegi Gabor gaborca websivision hu Fix found by anton@ OK anton@
Diffstat (limited to 'usr.sbin/httpd/server_http.c')
-rw-r--r--usr.sbin/httpd/server_http.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index b8146c3a115..5ee51b1925f 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.120 2018/06/11 12:12:51 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.121 2018/06/15 12:36:05 reyk Exp $ */
/*
* Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org>
@@ -1362,7 +1362,7 @@ server_response_http(struct client *clt, unsigned int code,
(error = server_httperror_byid(code)) == NULL)
return (-1);
- if (server_log_http(clt, code, size) == -1)
+ if (server_log_http(clt, code, size >= 0 ? size : 0) == -1)
return (-1);
/* Add error codes */
@@ -1388,9 +1388,9 @@ server_response_http(struct client *clt, unsigned int code,
return (-1);
/* Set content length, if specified */
- if ((cl =
+ if (size >= 0 && ((cl =
kv_add(&resp->http_headers, "Content-Length", NULL)) == NULL ||
- kv_set(cl, "%lld", (long long)size) == -1)
+ kv_set(cl, "%lld", (long long)size) == -1))
return (-1);
/* Set last modification time */
@@ -1423,7 +1423,7 @@ server_response_http(struct client *clt, unsigned int code,
server_bufferevent_print(clt, "\r\n") == -1)
return (-1);
- if (size == 0 || resp->http_method == HTTP_METHOD_HEAD) {
+ if (size <= 0 || resp->http_method == HTTP_METHOD_HEAD) {
bufferevent_enable(clt->clt_bev, EV_READ|EV_WRITE);
if (clt->clt_persist)
clt->clt_toread = TOREAD_HTTP_HEADER;