diff options
author | Valentin Bartenev <vbart@nginx.com> | 2018-06-25 16:51:47 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2018-06-25 16:51:47 +0300 |
commit | 1a52d876f7e10d07f58deee6faeaf70a11a6110f (patch) | |
tree | f69ba903180b3deac3bba2ee7acda9d34f18d73c /src/nxt_h1proto.c | |
parent | af31012815e20f0c92ed6ea803638a16ba47b0c2 (diff) | |
download | unit-1a52d876f7e10d07f58deee6faeaf70a11a6110f.tar.gz unit-1a52d876f7e10d07f58deee6faeaf70a11a6110f.tar.bz2 |
Introduced nxt_length() macro.
Diffstat (limited to 'src/nxt_h1proto.c')
-rw-r--r-- | src/nxt_h1proto.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c index c0be75e2..52a52f79 100644 --- a/src/nxt_h1proto.c +++ b/src/nxt_h1proto.c @@ -707,7 +707,7 @@ static const nxt_str_t nxt_http_server_error[] = { }; -#define UNKNOWN_STATUS_LENGTH (sizeof("HTTP/1.1 65536\r\n") - 1) +#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 65536\r\n") static void nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) @@ -766,16 +766,16 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) size = status->length; /* Trailing CRLF at the end of header. */ - size += sizeof("\r\n") - 1; + size += nxt_length("\r\n"); http11 = (h1p->parser.version.s.minor != '0'); if (r->resp.content_length == NULL || r->resp.content_length->skip) { if (http11) { h1p->chunked = 1; - size += sizeof(chunked) - 1; + size += nxt_length(chunked); /* Trailing CRLF will be added by the first chunk header. */ - size -= sizeof("\r\n") - 1; + size -= nxt_length("\r\n"); } else { h1p->keepalive = 0; @@ -793,7 +793,7 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) if (!field->skip) { size += field->name_length + field->value_length; - size += sizeof(": \r\n") - 1; + size += nxt_length(": \r\n"); } } nxt_list_loop; @@ -824,7 +824,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); + p = nxt_cpymem(p, chunked, nxt_length(chunked)); /* Trailing CRLF will be added by the first chunk header. */ } else { @@ -897,7 +897,7 @@ nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) nxt_off_t size; nxt_buf_t *b, **prev, *header, *tail; - const size_t chunk_size = 2 * (sizeof("\r\n") - 1) + NXT_OFF_T_HEXLEN; + const size_t chunk_size = 2 * nxt_length("\r\n") + NXT_OFF_T_HEXLEN; static const char tail_chunk[] = "\r\n0\r\n\r\n"; size = 0; @@ -918,7 +918,7 @@ nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) * memcpy may be inlined with just single 8 byte move operation. */ nxt_memcpy(tail->mem.free, tail_chunk, sizeof(tail_chunk)); - tail->mem.free += sizeof(tail_chunk) - 1; + tail->mem.free += nxt_length(tail_chunk); break; } |