Skip to content

Commit 5d64876

Browse files
authored
Merge pull request #1820 from tempesta-tech/kt-1103-h2-msg-trasform
Reworked HTTP1 -> HTTP2 message transformation
2 parents 94f8383 + 75012fb commit 5d64876

14 files changed

+622
-755
lines changed

fw/cache.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,17 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
847847

848848
resp->mit.start_off = FRAME_HEADER_SIZE;
849849

850-
r = tfw_h2_resp_status_write(resp, 304, TFW_H2_TRANS_EXPAND,
851-
true);
850+
r = tfw_h2_resp_status_write(resp, 304, false, true);
852851
if (unlikely(r))
853852
goto err_setup;
854-
h_len++; /* account for :status field itself */
853+
/* account for :status field itself */
854+
h_len++;
855+
856+
/*
857+
* Responses built from cache has room for frame header reserved
858+
* in SKB linear data.
859+
*/
860+
resp->mit.frame_head = it->skb_head->data;
855861
}
856862

857863
/* Put 304 headers */
@@ -2418,8 +2424,7 @@ tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce)
24182424

24192425
if (to_h2) {
24202426
h_age.hpack_idx = 21;
2421-
if ((r = tfw_hpack_encode(resp, &h_age, TFW_H2_TRANS_EXPAND,
2422-
false)))
2427+
if ((r = tfw_hpack_encode(resp, &h_age, false, false)))
24232428
goto err;
24242429
} else {
24252430
if ((r = tfw_http_msg_expand_data(&mit->iter, skb_head,
@@ -2560,11 +2565,17 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
25602565
|| (lifetime > ce->lifetime
25612566
&& tfw_h2_set_stale_warn(resp))
25622567
|| (!test_bit(TFW_HTTP_B_HDR_DATE, resp->flags)
2563-
&& tfw_h2_add_hdr_date(resp, TFW_H2_TRANS_EXPAND, true)))
2568+
&& tfw_h2_add_hdr_date(resp, true)))
25642569
goto free;
25652570

25662571
h_len += mit->acc_len;
25672572

2573+
/*
2574+
* Responses built from cache has room for frame header reserved
2575+
* in SKB linear data.
2576+
*/
2577+
resp->mit.frame_head = it->skb_head->data;
2578+
25682579
/*
25692580
* Split response to h2 frames. Don't write body with generic function,
25702581
* just indicate that we have body for correct framing.

0 commit comments

Comments
 (0)