diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-12-29 18:43:54 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-12-29 18:43:54 +0300 |
commit | bcbe6df8af4a9f20491d911d367da1b1e945d522 (patch) | |
tree | ad34e9da3221cdae28ce3b5c2d46b71bfcff0bdd /src | |
parent | 965a95d602cd2bb50111ba33e0a9efe3431b3674 (diff) | |
download | unit-bcbe6df8af4a9f20491d911d367da1b1e945d522.tar.gz unit-bcbe6df8af4a9f20491d911d367da1b1e945d522.tar.bz2 |
Corrected allocation size of HTTP response header.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_h1proto.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c index be9892c1..4203d62f 100644 --- a/src/nxt_h1proto.c +++ b/src/nxt_h1proto.c @@ -626,8 +626,9 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) status = &unknown_status; } - size = status->length + sizeof("\r\n"); - size += sizeof("\r\n"); /* Trailing CRLF. */ + size = status->length; + /* Trailing CRLF at the end of header. */ + size += sizeof("\r\n") - 1; http11 = (h1p->parser.version.str[7] != '0'); @@ -635,6 +636,8 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) if (http11) { h1p->chunked = 1; size += sizeof(chunked) - 1; + /* Trailing CRLF will be added by the first chunk header. */ + size -= sizeof("\r\n") - 1; } else { h1p->keepalive = 0; @@ -686,6 +689,7 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) if (h1p->chunked) { p = nxt_cpymem(p, chunked, sizeof(chunked) - 1); + /* Trailing CRLF will be added by the first chunk header. */ } else { *p++ = '\r'; *p++ = '\n'; |