X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fhttp.c;h=d16db355bc4840c1c7bc66ce15dd46a3febfcc1b;hp=6f53119479d9f0d42a0e4d51b3954069302ddd24;hb=4d32d8e976a69219ccbe14572d18e2e6fb75ed27;hpb=5f5ce1a79c4061098904a01ff9c9e723e9d6e7b9 diff --git a/src/http.c b/src/http.c index 6f53119..d16db35 100644 --- a/src/http.c +++ b/src/http.c @@ -573,21 +573,18 @@ int yaz_encode_http_response(ODR o, Z_HTTP_Response *hr) hr->code, z_HTTP_errmsg(hr->code)); odr_write2(o, sbuf, strlen(sbuf)); - /* apply Content-Length if not already applied */ - if (!z_HTTP_header_lookup(hr->headers, - "Content-Length")) - { - char lstr[60]; - sprintf(lstr, "Content-Length: %d\r\n", - hr->content_len); - odr_write2(o, lstr, strlen(lstr)); - } + /* use content_len for Content-Length */ + sprintf(sbuf, "Content-Length: %d\r\n", hr->content_len); + odr_write2(o, sbuf, strlen(sbuf)); for (h = hr->headers; h; h = h->next) { - odr_write2(o, h->name, strlen(h->name)); - odr_write2(o, ": ", 2); - odr_write2(o, h->value, strlen(h->value)); - odr_write2(o, "\r\n", 2); + if (yaz_matchstr(h->name, "Content-Length")) + { /* skip Content-Length if given. content_len rules */ + odr_write2(o, h->name, strlen(h->name)); + odr_write2(o, ": ", 2); + odr_write2(o, h->value, strlen(h->value)); + odr_write2(o, "\r\n", 2); + } } odr_write(o, (unsigned char *) "\r\n", 2); if (hr->content_buf)