struct htx_sl *sl = NULL;
unsigned int sl_flags = 0;
const char *ctl;
+ struct ist v;
lck = ck = -1; // no cookie for now
fields = 0;
continue;
}
- if (!htx_add_header(htx, list[idx].n, list[idx].v))
+ /* trim leading/trailing LWS as per RC9113#8.2.1 */
+ for (v = list[idx].v; v.len; v.len--) {
+ if (unlikely(HTTP_IS_LWS(*v.ptr)))
+ v.ptr++;
+ else if (!unlikely(HTTP_IS_LWS(v.ptr[v.len - 1])))
+ break;
+ }
+
+ if (!htx_add_header(htx, list[idx].n, v))
goto fail;
}
struct htx_sl *sl = NULL;
unsigned int sl_flags = 0;
const char *ctl;
+ struct ist v;
fields = 0;
for (idx = 0; list[idx].n.len != 0; idx++) {
isteq(list[idx].n, ist("transfer-encoding")))
goto fail;
- if (!htx_add_header(htx, list[idx].n, list[idx].v))
+ /* trim leading/trailing LWS as per RC9113#8.2.1 */
+ for (v = list[idx].v; v.len; v.len--) {
+ if (unlikely(HTTP_IS_LWS(*v.ptr)))
+ v.ptr++;
+ else if (!unlikely(HTTP_IS_LWS(v.ptr[v.len - 1])))
+ break;
+ }
+
+ if (!htx_add_header(htx, list[idx].n, v))
goto fail;
}
int h2_make_htx_trailers(struct http_hdr *list, struct htx *htx)
{
const char *ctl;
+ struct ist v;
uint32_t idx;
int i;
if (unlikely(ctl) && http_header_has_forbidden_char(list[idx].v, ctl))
goto fail;
- if (!htx_add_trailer(htx, list[idx].n, list[idx].v))
+ /* trim leading/trailing LWS as per RC9113#8.2.1 */
+ for (v = list[idx].v; v.len; v.len--) {
+ if (unlikely(HTTP_IS_LWS(*v.ptr)))
+ v.ptr++;
+ else if (!unlikely(HTTP_IS_LWS(v.ptr[v.len - 1])))
+ break;
+ }
+
+ if (!htx_add_trailer(htx, list[idx].n, v))
goto fail;
}
#include <haproxy/hpack-dec.h>
#include <haproxy/hpack-enc.h>
#include <haproxy/hpack-tbl.h>
+#include <haproxy/http.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/istbuf.h>
uint64_t mask, const struct ist trc_loc, const char *func,
const struct h2c *h2c, const struct h2s *h2s)
{
+ struct ist v;
int ret;
- ret = hpack_encode_header(buf, hn, hv);
+ /* trim leading/trailing LWS as per RC9113#8.2.1 */
+ for (v = hv; v.len; v.len--) {
+ if (unlikely(HTTP_IS_LWS(*v.ptr)))
+ v.ptr++;
+ else if (!unlikely(HTTP_IS_LWS(v.ptr[v.len - 1])))
+ break;
+ }
+
+ ret = hpack_encode_header(buf, hn, v);
if (ret)
- h2_trace_header(hn, hv, mask, trc_loc, func, h2c, h2s);
+ h2_trace_header(hn, v, mask, trc_loc, func, h2c, h2s);
return ret;
}