if (value == NULL) {
/* Do nothing. */
}
- else if (http_add_header(htx, ist_name, ist(value)) == 1) {
+ else if (http_add_header(htx, ist_name, ist(value), 1) == 1) {
retval = 0;
FLT_OT_DBG(3, "HTTP header '%s: %s' added", ist_name.ptr, value);
if (value == NULL) {
retval = 0;
}
- else if (http_add_header(htx, ist_name, ist(value)) == 1) {
+ else if (http_add_header(htx, ist_name, ist(value), 1) == 1) {
retval = 0;
OTELC_DBG(DEBUG, "HTTP header '%s: %s' added", ist_name.ptr, value);
int http_find_sfx_header(const struct htx *htx, const struct ist suffix, struct http_hdr_ctx *ctx, int full);
int http_find_sub_header(const struct htx *htx, const struct ist sub, struct http_hdr_ctx *ctx, int full);
int http_match_header(const struct htx *htx, const struct my_regex *re, struct http_hdr_ctx *ctx, int full);
-int http_add_header(struct htx *htx, const struct ist n, const struct ist v);
+int http_add_header(struct htx *htx, const struct ist n, const struct ist v, int update_authority);
int http_replace_stline(struct htx *htx, const struct ist p1, const struct ist p2, const struct ist p3);
int http_replace_req_meth(struct htx *htx, const struct ist meth);
int http_replace_req_uri(struct htx *htx, const struct ist uri);
age = CACHE_ENTRY_MAX_AGE;
end = ultoa_o(age, b_head(&trash), b_size(&trash));
b_set_data(&trash, end - b_head(&trash));
- if (!http_add_header(htx, ist("Age"), ist2(b_head(&trash), b_data(&trash))))
+ if (!http_add_header(htx, ist("Age"), ist2(b_head(&trash), b_data(&trash)), 0))
return 0;
return 1;
}
get_gmtime(date.tv_sec, &tm);
trash.data = strftime(trash.area, trash.size, "%a, %d %b %Y %T %Z", &tm);
if (trash.data)
- http_add_header(htx, ist("date"), ist2(trash.area, trash.data));
+ http_add_header(htx, ist("date"), ist2(trash.area, trash.data), 0);
}
/* Add the header "Content-Length:" if possible */
len += htx_get_blksz(blk);
}
end = ultoa_o(len, trash.area, trash.size);
- if (http_add_header(htx, ist("content-length"), ist2(trash.area, end-trash.area))) {
+ if (http_add_header(htx, ist("content-length"), ist2(trash.area, end-trash.area), 0)) {
sl->flags |= HTX_SL_F_CLEN;
msg->flags |= HTTP_MSGF_CNT_LEN;
}
pool_free(pool_head_fcgi_param_rule, param_rule);
continue;
}
- if (!http_add_header(htx, param_rule->name, ist2(value->area, value->data)))
+ if (!http_add_header(htx, param_rule->name, ist2(value->area, value->data), 1))
goto rewrite_err;
pool_free(pool_head_fcgi_param_rule, param_rule);
}
/* add "Transfer-Encoding: chunked" header */
if (!(msg->flags & HTTP_MSGF_TE_CHNK)) {
- if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked")))
+ if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked"), 0))
goto error;
msg->flags |= HTTP_MSGF_TE_CHNK;
sl->flags |= (HTX_SL_F_XFER_ENC|HTX_SL_F_CHNK);
if (ctx.blk == NULL) {
if (last_vary.blk == NULL) {
/* No Vary header found at all. Add our header */
- if (!http_add_header(htx, ist("Vary"), ist("Accept-Encoding")))
+ if (!http_add_header(htx, ist("Vary"), ist("Accept-Encoding"), 0))
goto error;
}
else {
if (comp_algo->cfg_name_len != 8 || memcmp(comp_algo->cfg_name, "identity", 8) != 0) {
struct ist v = ist2(comp_algo->ua_name, comp_algo->ua_name_len);
- if (!http_add_header(htx, ist("Content-Encoding"), v))
+ if (!http_add_header(htx, ist("Content-Encoding"), v, 0))
goto error;
}
struct htx *htx = htxbuf(&msg->chn->buf);
lua_pushboolean(L, http_add_header(htx, ist2(name, name_len),
- ist2(value, value_len)));
+ ist2(value, value_len), 1));
return 0;
}
goto success;
/* add "Transfer-Encoding: chunked" header */
- if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked")))
+ if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked"), 0))
goto failure;
msg->flags |= (HTTP_MSGF_VER_11|HTTP_MSGF_XFER_LEN|HTTP_MSGF_TE_CHNK);
sl->flags |= (HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_XFER_ENC|HTX_SL_F_CHNK);
}
/* Now add Content-Length header */
- if (!http_add_header(htx, ist("Content-Length"), ist(clen)))
+ if (!http_add_header(htx, ist("Content-Length"), ist(clen), 0))
goto failure;
msg->flags |= (HTTP_MSGF_VER_11|HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN);
sl->flags |= (HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN);
http_remove_header(htx, &ctx);
/* Now a the right XXX-Authenticate header */
- if (!http_add_header(htx, hdr, ist2(b_orig(&trash), b_data(&trash))))
+ if (!http_add_header(htx, hdr, ist2(b_orig(&trash), b_data(&trash)), 0))
goto fail;
/* Finally forward the reply */
}
/* Now add header */
- if (!http_add_header(htx, n, v))
+ if (!http_add_header(htx, n, v, 1))
goto fail_rewrite;
leave:
}
/* Now add header */
- if (!http_add_header(htx, n, v))
+ if (!http_add_header(htx, n, v, 1))
goto fail_rewrite;
}
ctx.blk = NULL;
if (!http_find_header(htx, ist("Early-Data"), &ctx, 0)) {
- if (unlikely(!http_add_header(htx, ist("Early-Data"), ist("1"))))
+ if (unlikely(!http_add_header(htx, ist("Early-Data"), ist("1"), 0)))
goto return_fail_rewrite;
}
}
/* send unique ID if a "unique-id-header" is defined */
if (isttest(sess->fe->header_unique_id) &&
- unlikely(!http_add_header(htx, sess->fe->header_unique_id, unique_id)))
+ unlikely(!http_add_header(htx, sess->fe->header_unique_id, unique_id, 1)))
goto return_fail_rewrite;
}
if (s->be->cookie_attrs)
chunk_appendf(&trash, "; %s", s->be->cookie_attrs);
- if (unlikely(!http_add_header(htx, ist("Set-Cookie"), ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, ist("Set-Cookie"), ist2(trash.area, trash.data), 0)))
goto return_fail_rewrite;
txn->flags &= ~TX_SCK_MASK;
txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK;
- if (unlikely(!http_add_header(htx, ist("Cache-control"), ist("private"))))
+ if (unlikely(!http_add_header(htx, ist("Cache-control"), ist("private"), 0)))
goto return_fail_rewrite;
}
}
return 0; /* htx error */
}
else {
- if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data), 0)))
return 0; /* htx error */
}
}
* on the frontend's header name.
*/
chunk_printf(&trash, "%d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
- if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data), 0)))
return 0;
}
}
* on the frontend's header name.
*/
chunk_printf(&trash, "%s", pn);
- if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data), 0)))
return 0;
}
}
* on the frontend's header name.
*/
chunk_printf(&trash, "%d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
- if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data), 0)))
return 0;
}
}
* on the frontend's header name.
*/
chunk_printf(&trash, "%s", pn);
- if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data))))
+ if (unlikely(!http_add_header(htx, hdr, ist2(trash.area, trash.data), 0)))
return 0;
}
}
/* Adds a header block int the HTX message <htx>, just before the EOH block. It
* returns 1 on success, otherwise it returns 0.
*/
-int http_add_header(struct htx *htx, const struct ist n, const struct ist v)
+int http_add_header(struct htx *htx, const struct ist n, const struct ist v, int update_authority)
{
struct htx_blk *blk;
struct htx_sl *sl;
}
end:
- sl = http_get_stline(htx);
- if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteqi(n, ist("host"))) {
- if (!http_update_authority(htx, sl, v))
- goto fail;
+ if (update_authority) {
+ sl = http_get_stline(htx);
+ if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteqi(n, ist("host"))) {
+ if (!http_update_authority(htx, sl, v))
+ goto fail;
+ }
}
return 1;