kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit cdd681d602980f8d6862a168eea5f3b40bd5a033
parent eb0b8f21e37113736602db9bba210496b860e186
Author: Joris Vink <joris@coders.se>
Date:   Sun, 12 Sep 2021 14:30:33 +0200

Let http_response_header() handle duplicates.

If a response header was previously by an application for an HTTP request
http_response_header() will now overwrite the previous value.

Diffstat:
src/http.c | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/http.c b/src/http.c @@ -400,11 +400,24 @@ http_response_header(struct http_request *req, { struct http_header *hdr; + hdr = NULL; kore_debug("http_response_header(%p, %s, %s)", req, header, value); - hdr = kore_pool_get(&http_header_pool); + TAILQ_FOREACH(hdr, &req->resp_headers, list) { + if (!strcasecmp(hdr->header, header)) { + TAILQ_REMOVE(&req->resp_headers, hdr, list); + kore_free(hdr->header); + kore_free(hdr->value); + break; + } + } + + if (hdr == NULL) + hdr = kore_pool_get(&http_header_pool); + hdr->header = kore_strdup(header); hdr->value = kore_strdup(value); + TAILQ_INSERT_TAIL(&(req->resp_headers), hdr, list); }