diff options
author | glen <glen@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2011-03-25 17:07:41 +0000 |
---|---|---|
committer | glen <glen@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2011-03-25 17:07:41 +0000 |
commit | 362d67ca62e990fd2dcf5029e04edafc29028079 (patch) | |
tree | 977dead2f4d2154a3b1a64ceec846dabb68c3755 | |
parent | 8748d6ea0cd70f6bcdbc7e7b46e1325d62c6236d (diff) | |
download | lighttpd-362d67ca62e990fd2dcf5029e04edafc29028079.tar.gz |
- Combine Cache-Control header value in mod_expire to existing HTTP header if header already added by other modules (fixes #2068)
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@2781 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/http-header-glue.c | 16 | ||||
-rw-r--r-- | src/mod_expire.c | 2 | ||||
-rw-r--r-- | src/response.h | 1 |
4 files changed, 19 insertions, 1 deletions
@@ -163,6 +163,7 @@ NEWS * Fix handling return value of SSL_CTX_set_options (fixes #2157, thx mlcreech) * Print double quotes properly when dumping config file (fixes #1806) * Include IP addresses on error log on password failures (fixes #2191) + * Combine Cache-Control header value in mod_expire to existing HTTP header if header already added by other modules (fixes #2068) - 1.5.0-r19.. - * -F option added for spawn-fcgi diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 02ceec83..a16eec49 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -109,6 +109,22 @@ int response_header_overwrite(server *srv, connection *con, const char *key, siz return response_header_insert(srv, con, key, keylen, value, vallen); } + +int response_header_append(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen) { + data_string *ds; + + UNUSED(srv); + + /* if there already is a key by this name append the value */ + if (NULL != (ds = (data_string *)array_get_element(con->response.headers, key, keylen))) { + buffer_append_string_len(ds->value, CONST_STR_LEN(", ")); + buffer_append_string_len(ds->value, value, vallen); + return 0; + } + + return response_header_insert(srv, con, key, keylen, value, vallen); +} + int http_response_redirect_to_directory(server *srv, connection *con) { buffer *o; diff --git a/src/mod_expire.c b/src/mod_expire.c index 888142e3..c844deeb 100644 --- a/src/mod_expire.c +++ b/src/mod_expire.c @@ -347,7 +347,7 @@ URIHANDLER_FUNC(mod_expire_path_handler) { buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age=")); buffer_append_long(p->expire_tstmp, expires - srv->cur_ts); /* as expires >= srv->cur_ts the difference is >= 0 */ - response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp)); + response_header_append(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp)); return HANDLER_GO_ON; } diff --git a/src/response.h b/src/response.h index d69ed9be..0a35debc 100644 --- a/src/response.h +++ b/src/response.h @@ -12,6 +12,7 @@ LI_API int http_response_write_header(server *srv, connection *con, chunkqueue * LI_API int response_header_insert(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); LI_API int response_header_overwrite(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); +LI_API int response_header_append(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen); LI_API handler_t handle_get_backend(server *srv, connection *con); LI_API int http_response_redirect_to_directory(server *srv, connection *con); |