int http_replace_res_reason(struct htx *htx, const struct ist reason);
int http_append_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data);
int http_prepend_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data);
-int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data);
-int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist name, const struct ist value);
+int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data, int update_authority);
+int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist name, const struct ist value, int update_authority);
int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx);
int http_update_authority(struct htx *htx, struct htx_sl *sl, const struct ist host);
int http_update_host(struct htx *htx, struct htx_sl *sl, const struct ist uri);
if (istcat(&v, ist("W/"), trash.size) == -1 || istcat(&v, ctx.value, trash.size) == -1)
goto error;
- if (!http_replace_header_value(htx, &ctx, v))
+ if (!http_replace_header_value(htx, &ctx, v, 0))
goto error;
}
}
output->data = exp_replace(output->area, output->size, ctx.value.ptr, str, pmatch);
if (output->data == -1)
return -1;
- if (!http_replace_header_value(htx, &ctx, ist2(output->area, output->data)))
+ if (!http_replace_header_value(htx, &ctx, ist2(output->area, output->data), 1))
return -1;
}
return 0;
ctx.value = ist2(val_beg, val_end - val_beg);
ctx.lws_before = ctx.lws_after = 0;
- http_replace_header_value(htx, &ctx, ist2(srv->cookie, srv->cklen));
+ http_replace_header_value(htx, &ctx, ist2(srv->cookie, srv->cklen), 0);
delta = srv->cklen - (val_end - val_beg);
sliding = (ctx.value.ptr - val_beg);
hdr_beg += sliding;
int sliding, delta;
ctx.value = ist2(val_beg, 0);
ctx.lws_before = ctx.lws_after = 0;
- http_replace_header_value(htx, &ctx, ist2(srv->cookie, srv->cklen + 1));
+ http_replace_header_value(htx, &ctx, ist2(srv->cookie, srv->cklen + 1), 0);
delta = srv->cklen + 1;
sliding = (ctx.value.ptr - val_beg);
hdr_beg += sliding;
* <data>. It returns 1 on success, otherwise it returns 0. The context is
* updated if necessary.
*/
-int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data)
+int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data,
+ int update_authority)
{
struct htx_blk *blk = ctx->blk;
struct htx_sl *sl;
goto fail;
v = htx_get_blk_value(htx, blk);
+ if (!update_authority)
+ goto out;
+
sl = http_get_stline(htx);
if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY)) {
struct ist n = htx_get_blk_name(htx, blk);
v = htx_get_blk_value(htx, blk);
}
}
-
+ out:
ctx->blk = blk;
ctx->value = ist2(v.ptr + off, data.len);
ctx->lws_before = ctx->lws_after = 0;
* context is updated if necessary.
*/
int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx,
- const struct ist name, const struct ist value)
+ const struct ist name, const struct ist value,
+ int update_authority)
{
struct htx_blk *blk = ctx->blk;
struct htx_sl *sl;
if (!blk)
goto fail;
+ if (!update_authority)
+ goto out;
+
sl = http_get_stline(htx);
if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteqi(name, ist("host"))) {
if (!http_update_authority(htx, sl, value))
blk = ctx->blk;
}
+ out:
ctx->blk = blk;
ctx->value = ist(NULL);
ctx->lws_before = ctx->lws_after = 0;
/* Replace header host value */
ctx.blk = NULL;
while (http_find_header(htx, ist("host"), &ctx, 1)) {
- if (!http_replace_header_value(htx, &ctx, authority))
+ if (!http_replace_header_value(htx, &ctx, authority, 0))
goto fail;
}
/* replace every host headers by the normalized host */
ctx.blk = NULL;
while (http_find_header(htx, ist("host"), &ctx, 1)) {
- if (!http_replace_header_value(htx, &ctx, host)) {
+ if (!http_replace_header_value(htx, &ctx, host, 0)) {
free_trash_chunk(temp);
goto fail;
}