diff --git a/include/common/chunk.h b/include/common/chunk.h index 18abca7bd..e44feea51 100644 --- a/include/common/chunk.h +++ b/include/common/chunk.h @@ -27,6 +27,7 @@ #include #include +#include #include @@ -117,6 +118,17 @@ static inline int chunk_cat(struct buffer *chk, const struct buffer *src) return 1; } +/* appends ist after . Returns 0 in case of failure. */ +static inline int chunk_istcat(struct buffer *chk, const struct ist src) +{ + if (unlikely(chk->data + src.len > chk->size)) + return 0; + + memcpy(chk->area + chk->data, src.ptr, src.len); + chk->data += src.len; + return 1; +} + /* copies memory area into for bytes. Returns 0 in * case of failure. No trailing zero is added. */ diff --git a/src/cache.c b/src/cache.c index 2ca745a94..8e2acd1cb 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1097,10 +1097,10 @@ int sha1_hosturi(struct stream *s) * well. */ if (!(sl->flags & HTX_SL_F_HAS_AUTHORITY)) { - chunk_cat(trash, b_fromist(ist("https://"))); + chunk_istcat(trash, ist("https://")); if (!http_find_header(htx, ist("Host"), &ctx, 0)) return 0; - chunk_cat(trash, b_fromist(ctx.value)); + chunk_istcat(trash, ctx.value); } chunk_memcat(trash, uri.ptr, uri.len);