[core] tst,set,clr macros for r->{rqst,resp}_htags

master
Glenn Strauss 3 years ago
parent c58b95f297
commit 9c8981a7d1

@ -217,6 +217,11 @@ static inline int light_isalnum(int c) {
#define light_isupper(c) ((uint32_t)(c)-'A' <= 'Z'-'A')
#define light_islower(c) ((uint32_t)(c)-'a' <= 'z'-'a')
#define light_bshift(b) (b)
#define light_btst(a,b) ((a) & (b))
#define light_bclr(a,b) ((a) &= ~(b))
#define light_bset(a,b) ((a) |= (b))
__attribute_pure__
static inline uint32_t buffer_string_length(const buffer *b); /* buffer string length without terminating 0 */

@ -1137,7 +1137,7 @@ h2_recv_headers (connection * const con, uint8_t * const s, uint32_t flen)
if (!h2c->sent_goaway) {
h2c->h2_cid = id;
if (!(r->rqst_htags & HTTP_HEADER_CONTENT_LENGTH))
if (!light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_LENGTH))
r->reqbody_length = (s[4] & H2_FLAG_END_STREAM) ? 0 : -1;
#if 0
else if (r->reqbody_length > 0 && (s[4] & H2_FLAG_END_STREAM)) {
@ -1580,7 +1580,8 @@ h2_send_headers (request_st * const r, connection * const con)
/* specialized version of http_response_write_header(); send headers
* directly to HPACK encoder, rather than double-buffering in chunkqueue */
if (304 == r->http_status && (r->resp_htags & HTTP_HEADER_CONTENT_ENCODING))
if (304 == r->http_status
&& light_btst(r->resp_htags, HTTP_HEADER_CONTENT_ENCODING))
http_header_response_unset(r, HTTP_HEADER_CONTENT_ENCODING,
CONST_STR_LEN("Content-Encoding"));
@ -1684,7 +1685,7 @@ h2_send_headers (request_st * const r, connection * const con)
buffer_string_set_length(&ds->value, vlen); /*(restore prior value)*/
}
if (!(r->resp_htags & HTTP_HEADER_DATE)) {
if (!light_btst(r->resp_htags, HTTP_HEADER_DATE)) {
/* HTTP/1.1 and later requires a Date: header */
/* "date: " 6-chars + 30-chars for "%a, %d %b %Y %H:%M:%S GMT" + '\0' */
static char tstr[36] = "date: ";
@ -1718,7 +1719,7 @@ h2_send_headers (request_st * const r, connection * const con)
}
}
if (!(r->resp_htags & HTTP_HEADER_SERVER)
if (!light_btst(r->resp_htags, HTTP_HEADER_SERVER)
&& !buffer_string_is_empty(r->conf.server_tag)) {
buffer * const b = chunk_buffer_acquire();
const uint32_t vlen = buffer_string_length(r->conf.server_tag);

@ -246,12 +246,12 @@ int http_response_handle_cachable(request_st * const r, const buffer * const mti
void http_response_body_clear (request_st * const r, int preserve_length) {
r->resp_send_chunked = 0;
if (r->resp_htags & HTTP_HEADER_TRANSFER_ENCODING) {
if (light_btst(r->resp_htags, HTTP_HEADER_TRANSFER_ENCODING)) {
http_header_response_unset(r, HTTP_HEADER_TRANSFER_ENCODING, CONST_STR_LEN("Transfer-Encoding"));
}
if (!preserve_length) { /* preserve for HEAD responses and no-content responses (204, 205, 304) */
r->content_length = -1;
if (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH) {
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH)) {
http_header_response_unset(r, HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length"));
}
/*(if not preserving Content-Length, do not preserve trailers, if any)*/
@ -678,7 +678,7 @@ static void http_response_xsendfile (request_st * const r, buffer * const path,
* Content-Length might later be set to size of X-Sendfile static file,
* determined by open(), fstat() to reduces race conditions if the file
* is modified between stat() (stat_cache_get_entry()) and open(). */
if (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH) {
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH)) {
http_header_response_unset(r, HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length"));
r->content_length = -1;
}
@ -738,7 +738,7 @@ static void http_response_xsendfile2(request_st * const r, const buffer * const
const int status = r->http_status;
/* reset Content-Length, if set by backend */
if (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH) {
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH)) {
http_header_response_unset(r, HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length"));
r->content_length = -1;
}
@ -953,8 +953,8 @@ static handler_t http_response_process_local_redir(request_st * const r, size_t
|| ( vb->ptr[ulen] != '\0'
&& vb->ptr[ulen] != '/'
&& vb->ptr[ulen] != '?'))
&& 0 == blen
&& !(r->resp_htags & HTTP_HEADER_STATUS) /*no "Status" or NPH response*/
&& 0 == blen /*no "Status" or NPH response*/
&& !light_btst(r->resp_htags, HTTP_HEADER_STATUS)
&& 1 == r->resp_headers.used) {
if (++r->loops_per_request > 5) {
log_error(r->conf.errh, __FILE__, __LINE__,
@ -1015,7 +1015,7 @@ static int http_response_process_headers(request_st * const r, http_response_opt
int status = http_header_str_to_code(s+9);
if (status >= 100 && status < 1000) {
status_is_set = 1;
r->resp_htags |= HTTP_HEADER_STATUS;
light_bset(r->resp_htags, HTTP_HEADER_STATUS);
r->http_status = status;
} /* else we expected 3 digits and didn't get them */
}
@ -1122,7 +1122,7 @@ static int http_response_process_headers(request_st * const r, http_response_opt
/* CGI/1.1 rev 03 - 7.2.1.2 */
/* (proxy requires Status-Line, so never true for proxy)*/
if (!status_is_set && (r->resp_htags & HTTP_HEADER_LOCATION)) {
if (!status_is_set && light_btst(r->resp_htags, HTTP_HEADER_LOCATION)) {
r->http_status = 302;
}
@ -1286,7 +1286,7 @@ handler_t http_response_parse_headers(request_st * const r, http_response_opts *
}
if (opts->local_redir && r->http_status >= 300 && r->http_status < 400){
/*(r->resp_htags & HTTP_HEADER_LOCATION)*/
/*(light_btst(r->resp_htags, HTTP_HEADER_LOCATION))*/
handler_t rc = http_response_process_local_redir(r, blen);
if (NULL == r->handler_module)
r->resp_body_started = 0;

@ -156,14 +156,14 @@ static inline buffer * http_header_generic_get_ifnotempty(const array * const a,
buffer * http_header_response_get(const request_st * const r, enum http_header_e id, const char *k, uint32_t klen) {
return (id <= HTTP_HEADER_OTHER || (r->resp_htags & id))
return (id <= HTTP_HEADER_OTHER || light_btst(r->resp_htags, id))
? http_header_generic_get_ifnotempty(&r->resp_headers, k, klen)
: NULL;
}
void http_header_response_unset(request_st * const r, enum http_header_e id, const char *k, uint32_t klen) {
if (id <= HTTP_HEADER_OTHER || (r->resp_htags & id)) {
if (id > HTTP_HEADER_OTHER) r->resp_htags &= ~id;
if (id <= HTTP_HEADER_OTHER || light_btst(r->resp_htags, id)) {
if (id > HTTP_HEADER_OTHER) light_bclr(r->resp_htags, id);
array_set_key_value(&r->resp_headers, k, klen, CONST_STR_LEN(""));
}
}
@ -174,20 +174,20 @@ void http_header_response_set(request_st * const r, enum http_header_e id, const
* which is used to indicate a "removed" header)
*/
if (id > HTTP_HEADER_OTHER)
(vlen) ? (r->resp_htags |= id) : (r->resp_htags &= ~id);
(vlen) ? light_bset(r->resp_htags, id) : light_bclr(r->resp_htags, id);
array_set_key_value(&r->resp_headers, k, klen, v, vlen);
}
void http_header_response_append(request_st * const r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen) {
if (0 == vlen) return;
if (id > HTTP_HEADER_OTHER) r->resp_htags |= id;
if (id > HTTP_HEADER_OTHER) light_bset(r->resp_htags, id);
buffer * const vb = array_get_buf_ptr(&r->resp_headers, k, klen);
http_header_token_append(vb, v, vlen);
}
void http_header_response_insert(request_st * const r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen) {
if (0 == vlen) return;
if (id > HTTP_HEADER_OTHER) r->resp_htags |= id;
if (id > HTTP_HEADER_OTHER) light_bset(r->resp_htags, id);
buffer * const vb = array_get_buf_ptr(&r->resp_headers, k, klen);
if (!buffer_string_is_empty(vb)) { /* append value */
buffer_append_string_len(vb, CONST_STR_LEN("\r\n"));
@ -207,14 +207,14 @@ void http_header_response_insert(request_st * const r, enum http_header_e id, co
buffer * http_header_request_get(const request_st * const r, enum http_header_e id, const char *k, uint32_t klen) {
return (id <= HTTP_HEADER_OTHER || (r->rqst_htags & id))
return (id <= HTTP_HEADER_OTHER || light_btst(r->rqst_htags, id))
? http_header_generic_get_ifnotempty(&r->rqst_headers, k, klen)
: NULL;
}
void http_header_request_unset(request_st * const r, enum http_header_e id, const char *k, uint32_t klen) {
if (id <= HTTP_HEADER_OTHER || (r->rqst_htags & id)) {
if (id > HTTP_HEADER_OTHER) r->rqst_htags &= ~id;
if (id <= HTTP_HEADER_OTHER || light_btst(r->rqst_htags, id)) {
if (id > HTTP_HEADER_OTHER) light_bclr(r->rqst_htags, id);
array_set_key_value(&r->rqst_headers, k, klen, CONST_STR_LEN(""));
}
}
@ -225,13 +225,13 @@ void http_header_request_set(request_st * const r, enum http_header_e id, const
* which is used to indicate a "removed" header)
*/
if (id > HTTP_HEADER_OTHER)
(vlen) ? (r->rqst_htags |= id) : (r->rqst_htags &= ~id);
(vlen) ? light_bset(r->rqst_htags, id) : light_bclr(r->rqst_htags, id);
array_set_key_value(&r->rqst_headers, k, klen, v, vlen);
}
void http_header_request_append(request_st * const r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen) {
if (0 == vlen) return;
if (id > HTTP_HEADER_OTHER) r->rqst_htags |= id;
if (id > HTTP_HEADER_OTHER) light_bset(r->rqst_htags, id);
buffer * const vb = array_get_buf_ptr(&r->rqst_headers, k, klen);
if (id != HTTP_HEADER_COOKIE)
http_header_token_append(vb, v, vlen);

@ -398,13 +398,13 @@ static handler_t cgi_response_headers(request_st * const r, struct http_response
/* response headers just completed */
handler_ctx *hctx = (handler_ctx *)opts->pdata;
if (r->resp_htags & HTTP_HEADER_UPGRADE) {
if (light_btst(r->resp_htags, HTTP_HEADER_UPGRADE)) {
if (hctx->conf.upgrade && r->http_status == 101) {
/* 101 Switching Protocols; transition to transparent proxy */
http_response_upgrade_read_body_unknown(r);
}
else {
r->resp_htags &= ~HTTP_HEADER_UPGRADE;
light_bclr(r->resp_htags, HTTP_HEADER_UPGRADE);
#if 0
/* preserve prior questionable behavior; likely broken behavior
* anyway if backend thinks connection is being upgraded but client
@ -415,7 +415,8 @@ static handler_t cgi_response_headers(request_st * const r, struct http_response
}
}
if (hctx->conf.upgrade && !(r->resp_htags & HTTP_HEADER_UPGRADE)) {
if (hctx->conf.upgrade
&& !light_btst(r->resp_htags, HTTP_HEADER_UPGRADE)) {
chunkqueue *cq = r->reqbody_queue;
hctx->conf.upgrade = 0;
if (cq->bytes_out == (off_t)r->reqbody_length) {

@ -1384,8 +1384,10 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
/*(current implementation requires response be complete)*/
if (!r->resp_body_finished) return HANDLER_GO_ON;
if (r->http_method == HTTP_METHOD_HEAD) return HANDLER_GO_ON;
if (r->resp_htags & HTTP_HEADER_TRANSFER_ENCODING) return HANDLER_GO_ON;
if (r->resp_htags & HTTP_HEADER_CONTENT_ENCODING) return HANDLER_GO_ON;
if (light_btst(r->resp_htags, HTTP_HEADER_TRANSFER_ENCODING))
return HANDLER_GO_ON;
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_ENCODING))
return HANDLER_GO_ON;
/* disable compression for some http status types. */
switch(r->http_status) {
@ -1447,7 +1449,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
* (slightly imperfect (close enough?) match of ETag "000000" to "000000-gzip") */
vb = http_header_response_get(r, HTTP_HEADER_ETAG, CONST_STR_LEN("ETag"));
etaglen = (NULL != vb) ? buffer_string_length(vb) : 0;
if (NULL != vb && (r->rqst_htags & HTTP_HEADER_IF_NONE_MATCH)) {
if (NULL != vb && light_btst(r->rqst_htags, HTTP_HEADER_IF_NONE_MATCH)) {
const buffer *if_none_match = http_header_response_get(r, HTTP_HEADER_IF_NONE_MATCH, CONST_STR_LEN("If-None-Match"));
if (etaglen
&& r->http_status < 300 /*(want 2xx only)*/
@ -1539,7 +1541,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
chunkqueue_reset(r->write_queue);
if (0 != http_chunk_append_file(r, tb))
return HANDLER_ERROR;
if (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH)
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH))
http_header_response_unset(r, HTTP_HEADER_CONTENT_LENGTH,
CONST_STR_LEN("Content-Length"));
mod_deflate_note_ratio(r, sce->st.st_size, len);
@ -1587,7 +1589,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
BrotliEncoderSetParameter(hctx->u.br, BROTLI_PARAM_SIZE_HINT, (uint32_t)len);
#endif
if (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH) {
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH)) {
http_header_response_unset(r, HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length"));
}
r->plugin_ctx[p->id] = hctx;

@ -1061,14 +1061,14 @@ static handler_t proxy_response_headers(request_st * const r, struct http_respon
/* response headers just completed */
handler_ctx *hctx = (handler_ctx *)opts->pdata;
if (r->resp_htags & HTTP_HEADER_UPGRADE) {
if (light_btst(r->resp_htags, HTTP_HEADER_UPGRADE)) {
if (hctx->conf.header.upgrade && r->http_status == 101) {
/* 101 Switching Protocols; transition to transparent proxy */
gw_set_transparent(&hctx->gw);
http_response_upgrade_read_body_unknown(r);
}
else {
r->resp_htags &= ~HTTP_HEADER_UPGRADE;
light_bclr(r->resp_htags, HTTP_HEADER_UPGRADE);
#if 0
/* preserve prior questionable behavior; likely broken behavior
* anyway if backend thinks connection is being upgraded but client
@ -1085,15 +1085,15 @@ static handler_t proxy_response_headers(request_st * const r, struct http_respon
&& NULL == hctx->conf.header.hosts_response)
return HANDLER_GO_ON;
if (r->resp_htags & HTTP_HEADER_LOCATION) {
if (light_btst(r->resp_htags, HTTP_HEADER_LOCATION)) {
buffer *vb = http_header_response_get(r, HTTP_HEADER_LOCATION, CONST_STR_LEN("Location"));
if (vb) http_header_remap_uri(vb, 0, &hctx->conf.header, 0);
}
if (r->resp_htags & HTTP_HEADER_CONTENT_LOCATION) {
if (light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LOCATION)) {
buffer *vb = http_header_response_get(r, HTTP_HEADER_CONTENT_LOCATION, CONST_STR_LEN("Content-Location"));
if (vb) http_header_remap_uri(vb, 0, &hctx->conf.header, 0);
}
if (r->resp_htags & HTTP_HEADER_SET_COOKIE) {
if (light_btst(r->resp_htags, HTTP_HEADER_SET_COOKIE)) {
buffer *vb = http_header_response_get(r, HTTP_HEADER_SET_COOKIE, CONST_STR_LEN("Set-Cookie"));
if (vb) http_header_remap_setcookie(vb, 0, &hctx->conf.header);
}

@ -422,7 +422,7 @@ static int http_request_parse_single_header(request_st * const restrict r, const
default:
break;
case HTTP_HEADER_HOST:
if (!(r->rqst_htags & HTTP_HEADER_HOST)) {
if (!light_btst(r->rqst_htags, HTTP_HEADER_HOST)) {
saveb = &r->http_host;
if (vlen >= 1024) { /*(expecting < 256)*/
return http_request_header_line_invalid(r, 400, "uri-authority too long -> 400");
@ -450,18 +450,18 @@ static int http_request_parse_single_header(request_st * const restrict r, const
}
break;
case HTTP_HEADER_CONTENT_TYPE:
if (r->rqst_htags & HTTP_HEADER_CONTENT_TYPE) {
if (light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_TYPE)) {
return http_request_header_line_invalid(r, 400, "duplicate Content-Type header -> 400");
}
break;
case HTTP_HEADER_IF_NONE_MATCH:
/* if dup, only the first one will survive */
if (r->rqst_htags & HTTP_HEADER_IF_NONE_MATCH) {
if (light_btst(r->rqst_htags, HTTP_HEADER_IF_NONE_MATCH)) {
return 0; /* ignore header */
}
break;
case HTTP_HEADER_CONTENT_LENGTH:
if (!(r->rqst_htags & HTTP_HEADER_CONTENT_LENGTH)) {
if (!light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_LENGTH)) {
/*(trailing whitespace was removed from vlen)*/
/*(not using strtoll() since v might not be z-string)*/
const char *err;
@ -479,12 +479,12 @@ static int http_request_parse_single_header(request_st * const restrict r, const
}
break;
case HTTP_HEADER_HTTP2_SETTINGS:
if (r->rqst_htags & HTTP_HEADER_HTTP2_SETTINGS) {
if (light_btst(r->rqst_htags, HTTP_HEADER_HTTP2_SETTINGS)) {
return http_request_header_line_invalid(r, 400, "duplicate HTTP2-Settings header -> 400");
}
break;
case HTTP_HEADER_IF_MODIFIED_SINCE:
if (r->rqst_htags & HTTP_HEADER_IF_MODIFIED_SINCE) {
if (light_btst(r->rqst_htags, HTTP_HEADER_IF_MODIFIED_SINCE)) {
/* Proxies sometimes send dup headers
* if they are the same we ignore the second
* if not, we raise an error */
@ -1235,14 +1235,14 @@ http_request_parse (request_st * const restrict r, const int scheme_port)
/* POST requires Content-Length (or Transfer-Encoding)
* (-1 == r->reqbody_length when Transfer-Encoding: chunked)*/
if (HTTP_METHOD_POST == r->http_method
&& !(r->rqst_htags & HTTP_HEADER_CONTENT_LENGTH)) {
&& !light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_LENGTH)) {
return http_request_header_line_invalid(r, 411, "POST-request, but content-length missing -> 411");
}
}
else {
/* (-1 == r->reqbody_length when Transfer-Encoding: chunked)*/
if (-1 == r->reqbody_length
&& (r->rqst_htags & HTTP_HEADER_CONTENT_LENGTH)) {
&& light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_LENGTH)) {
/* RFC7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
* 3.3.3. Message Body Length
* [...]
@ -1347,7 +1347,7 @@ http_request_headers_process_h2 (request_st * const restrict r, const int scheme
r->http_status = http_request_parse(r, scheme_port);
if (0 == r->http_status) {
if (r->rqst_htags & HTTP_HEADER_CONNECTION)
if (light_btst(r->rqst_htags, HTTP_HEADER_CONNECTION))
r->http_status = http_request_header_line_invalid(r, 400,
"invalid Connection header with HTTP/2 -> 400");
}
@ -1364,7 +1364,7 @@ http_request_headers_process_h2 (request_st * const restrict r, const int scheme
#endif
/* ignore Upgrade if using HTTP/2 */
if (r->rqst_htags & HTTP_HEADER_UPGRADE)
if (light_btst(r->rqst_htags, HTTP_HEADER_UPGRADE))
http_header_request_unset(r, HTTP_HEADER_UPGRADE,
CONST_STR_LEN("upgrade"));
/* XXX: should filter out other hop-by-hop connection headers, too */

@ -74,7 +74,8 @@ http_response_write_header (request_st * const r)
r->con->keep_alive_idle = r->conf.max_keep_alive_idle;
}
if ((r->resp_htags & HTTP_HEADER_UPGRADE) && r->http_version == HTTP_VERSION_1_1) {
if (light_btst(r->resp_htags, HTTP_HEADER_UPGRADE)
&& r->http_version == HTTP_VERSION_1_1) {
http_header_response_set(r, HTTP_HEADER_CONNECTION, CONST_STR_LEN("Connection"), CONST_STR_LEN("upgrade"));
} else if (0 == r->keep_alive) {
http_header_response_set(r, HTTP_HEADER_CONNECTION, CONST_STR_LEN("Connection"), CONST_STR_LEN("close"));
@ -82,7 +83,8 @@ http_response_write_header (request_st * const r)
http_header_response_set(r, HTTP_HEADER_CONNECTION, CONST_STR_LEN("Connection"), CONST_STR_LEN("keep-alive"));
}
if (304 == r->http_status && (r->resp_htags & HTTP_HEADER_CONTENT_ENCODING)) {
if (304 == r->http_status
&& light_btst(r->resp_htags, HTTP_HEADER_CONTENT_ENCODING)) {
http_header_response_unset(r, HTTP_HEADER_CONTENT_ENCODING, CONST_STR_LEN("Content-Encoding"));
}
@ -101,7 +103,7 @@ http_response_write_header (request_st * const r)
buffer_append_string_buffer(b, &ds->value);
}
if (!(r->resp_htags & HTTP_HEADER_DATE)) {
if (!light_btst(r->resp_htags, HTTP_HEADER_DATE)) {
static time_t tlast;
static char tstr[32]; /* 30-chars for "%a, %d %b %Y %H:%M:%S GMT" */
static size_t tlen;
@ -119,7 +121,7 @@ http_response_write_header (request_st * const r)
buffer_append_string_len(b, tstr, tlen);
}
if (!(r->resp_htags & HTTP_HEADER_SERVER)) {
if (!light_btst(r->resp_htags, HTTP_HEADER_SERVER)) {
if (!buffer_string_is_empty(r->conf.server_tag)) {
buffer_append_string_len(b, CONST_STR_LEN("\r\nServer: "));
buffer_append_string_len(b, CONST_BUF_LEN(r->conf.server_tag));
@ -138,7 +140,8 @@ http_response_write_header (request_st * const r)
/*(optimization to use fewer syscalls to send a small response)*/
off_t cqlen;
if (r->resp_body_finished && (r->resp_htags & HTTP_HEADER_CONTENT_LENGTH)
if (r->resp_body_finished
&& light_btst(r->resp_htags, HTTP_HEADER_CONTENT_LENGTH)
&& (cqlen = chunkqueue_length(cq) - r->resp_header_len) > 0
&& cqlen <= 32768)
chunkqueue_small_resp_optim(cq);
@ -841,7 +844,8 @@ http_response_write_prepare(request_st * const r)
if (r->resp_body_finished) {
/* set content-length if length is known and not already set */
if (!(r->resp_htags
& (HTTP_HEADER_CONTENT_LENGTH | HTTP_HEADER_TRANSFER_ENCODING))) {
& (light_bshift(HTTP_HEADER_CONTENT_LENGTH)
|light_bshift(HTTP_HEADER_TRANSFER_ENCODING)))) {
off_t qlen = chunkqueue_length(r->write_queue);
/**
* The Content-Length header can only be sent if we have content:
@ -886,9 +890,9 @@ http_response_write_prepare(request_st * const r)
*/
if (!(r->resp_htags
& (HTTP_HEADER_CONTENT_LENGTH
|HTTP_HEADER_TRANSFER_ENCODING
|HTTP_HEADER_UPGRADE))) {
& (light_bshift(HTTP_HEADER_CONTENT_LENGTH)
|light_bshift(HTTP_HEADER_TRANSFER_ENCODING)
|light_bshift(HTTP_HEADER_UPGRADE)))) {
if (r->http_method == HTTP_METHOD_CONNECT && r->http_status == 200){
/*(no transfer-encoding if successful CONNECT)*/
}

Loading…
Cancel
Save