mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-15 10:29:47 +00:00
Fix #1558 - add opts.extra_headers in 304 responses
This commit is contained in:
1 parent
e2ce68e3ef
commit
65957527cb
3 files changed
+8
-2
No files matched your search
+2
-1
@@ -1445,7 +1445,8 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
|
||||
(inm = mg_http_get_header(hm, "If-None-Match")) != NULL &&
|
||||
mg_vcasecmp(inm, etag) == 0) {
|
||||
mg_fs_close(fd);
|
||||
mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n");
|
||||
mg_printf(c, "HTTP/1.1 304 Not Modified\r\n%sContent-Length: 0\r\n\r\n",
|
||||
opts->extra_headers ? opts->extra_headers : "");
|
||||
} else {
|
||||
int n, status = 200;
|
||||
char range[100] = "";
|
||||
|
||||
+2
-1
@@ -451,7 +451,8 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
|
||||
(inm = mg_http_get_header(hm, "If-None-Match")) != NULL &&
|
||||
mg_vcasecmp(inm, etag) == 0) {
|
||||
mg_fs_close(fd);
|
||||
mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n");
|
||||
mg_printf(c, "HTTP/1.1 304 Not Modified\r\n%sContent-Length: 0\r\n\r\n",
|
||||
opts->extra_headers ? opts->extra_headers : "");
|
||||
} else {
|
||||
int n, status = 200;
|
||||
char range[100] = "";
|
||||
|
||||
@@ -655,6 +655,7 @@ static void test_http_server(void) {
|
||||
|
||||
{
|
||||
extern char *mg_http_etag(char *, size_t, size_t, time_t);
|
||||
struct mg_http_message hm;
|
||||
char etag[100];
|
||||
size_t size = 0;
|
||||
time_t mtime = 0;
|
||||
@@ -662,6 +663,9 @@ static void test_http_server(void) {
|
||||
ASSERT(mg_http_etag(etag, sizeof(etag), size, mtime) == etag);
|
||||
ASSERT(fetch(&mgr, buf, url, "GET /a.txt HTTP/1.0\nIf-None-Match: %s\n\n",
|
||||
etag) == 304);
|
||||
mg_http_parse(buf, strlen(buf), &hm);
|
||||
ASSERT(mg_http_get_header(&hm, "A") != NULL);
|
||||
ASSERT(mg_strcmp(*mg_http_get_header(&hm, "A"), mg_str("B")) == 0);
|
||||
}
|
||||
|
||||
// Text mime type override
|
||||
|
||||
Reference in new issue
Block a user