h2_do_shutw(h2s);
}
-/* Decode the payload of a HEADERS frame and produce the equivalent HTTP/1
- * request. Returns the number of bytes emitted if > 0, or 0 if it couldn't
- * proceed. Stream errors are reported in h2s->errcode and connection errors
- * in h2c->errcode.
+/* Decode the payload of a HEADERS frame and produce the equivalent HTTP/1 or
+ * HTX request. Returns the number of bytes emitted if > 0, or 0 if it couldn't
+ * proceed. Stream errors are reported in h2s->errcode and connection errors in
+ * h2c->errcode.
*/
static int h2_frt_decode_headers(struct h2s *h2s)
{
struct buffer *copy = NULL;
unsigned int msgf;
struct buffer *csbuf;
+ struct htx *htx = NULL;
int flen = h2c->dfl;
int outlen = 0;
int wrap;
- int try;
+ int try = 0;
if (!h2c->dfl) {
h2s_error(h2s, H2_ERR_PROTOCOL_ERROR); // empty headers frame!
* always empty except maybe for trailers, in which case we simply have
* to wait for the upper layer to finish consuming what is available.
*/
- if (b_data(csbuf))
- goto fail;
- csbuf->head = 0;
- try = b_size(csbuf);
+ if (h2c->proxy->options2 & PR_O2_USE_HTX) {
+ htx = htx_from_buf(&h2s->rxbuf);
+ if (!htx_is_empty(htx))
+ goto fail;
+ } else {
+ if (b_data(csbuf))
+ goto fail;
+
+ csbuf->head = 0;
+ try = b_size(csbuf);
+ }
outlen = hpack_decode_frame(h2c->ddht, hdrs, flen, list,
sizeof(list)/sizeof(list[0]), tmp);
/* OK now we have our header list in <list> */
msgf = (h2c->dff & H2_F_DATA_END_STREAM) ? 0 : H2_MSGF_BODY;
- outlen = h2_make_h1_request(list, b_tail(csbuf), try, &msgf);
+
+ if (htx)
+ outlen = h2_make_htx_request(list, htx, &msgf);
+ else
+ outlen = h2_make_h1_request(list, b_tail(csbuf), try, &msgf);
if (outlen < 0) {
h2c_error(h2c, H2_ERR_COMPRESSION_ERROR);
if (h2c->dff & H2_F_HEADERS_END_STREAM) {
h2s->flags |= H2_SF_ES_RCVD;
h2s->cs->flags |= CS_FL_REOS;
+ if (htx)
+ htx_add_endof(htx, HTX_BLK_EOM);
}
leave: