@@ -633,8 +633,7 @@ tfw_h2_prep_resp(TfwHttpResp *resp, unsigned short status, TfwStr *msg,
633
633
__TFW_STR_CH (& hdr , 1 )-> len ;
634
634
hdr .hpack_idx = name -> hpack_idx ;
635
635
636
- if ((r = tfw_hpack_encode (resp , & hdr ,
637
- false, true)))
636
+ if ((r = tfw_hpack_encode (resp , & hdr , false, true)))
638
637
return r ;
639
638
}
640
639
}
@@ -4700,162 +4699,6 @@ tfw_h2_hpack_encode_headers(TfwHttpResp *resp, const TfwHdrMods *h_mods)
4700
4699
return 0 ;
4701
4700
}
4702
4701
4703
- /*
4704
- * Get next header from the @mit->map. Procedure designed to be called from the
4705
- * outer cycle with changing of @mit iterator (including @mit->curr index of
4706
- * current header in the indirection map). Note, for optimization purposes, on
4707
- * each iteration function produces the boundary pointer @mit->bnd for current
4708
- * iteration and the operation instance @mit->next - for the next iteration
4709
- * (including source header @mit->next.s_hdr).
4710
- *
4711
- * TODO #1103: This function should be treated as a foundation for #1103 issue.
4712
- */
4713
- static int
4714
- tfw_h2_resp_next_hdr (TfwHttpResp * resp , const TfwHdrMods * h_mods )
4715
- {
4716
- int r ;
4717
- unsigned int i ;
4718
- TfwHttpTransIter * mit = & resp -> mit ;
4719
- TfwHttpHdrMap * map = mit -> map ;
4720
- TfwNextHdrOp * next = & mit -> next ;
4721
- TfwHttpHdrTbl * ht = resp -> h_tbl ;
4722
-
4723
- mit -> bnd = NULL ;
4724
-
4725
- for (i = mit -> curr ; i < map -> count ; ++ i ) {
4726
- int k ;
4727
- TfwStr * first ;
4728
- unsigned short hid = map -> index [i ].idx ;
4729
- unsigned short d_num = map -> index [i ].d_idx ;
4730
- TfwStr * tgt = & ht -> tbl [hid ];
4731
- TfwHdrModsDesc * f_desc = NULL ;
4732
- const TfwStr * val ;
4733
-
4734
- if (TFW_STR_DUP (tgt ))
4735
- tgt = TFW_STR_CHUNK (tgt , d_num );
4736
-
4737
- first = TFW_STR_CHUNK (tgt , 0 );
4738
-
4739
- if (WARN_ON_ONCE (!tgt
4740
- || TFW_STR_EMPTY (tgt )
4741
- || TFW_STR_DUP (tgt )))
4742
- return - EINVAL ;
4743
-
4744
- T_DBG3 ("%s: hid=%hu, d_num=%hu, nchunks=%u, h_mods->sz=%lu\n" ,
4745
- __func__ , hid , d_num , ht -> tbl [hid ].nchunks ,
4746
- h_mods ? h_mods -> sz : 0 );
4747
-
4748
- if (!h_mods )
4749
- goto def ;
4750
-
4751
- for (k = 0 ; k < h_mods -> sz ; ++ k ) {
4752
- TfwHdrModsDesc * desc = & h_mods -> hdrs [k ];
4753
-
4754
- if ((hid < TFW_HTTP_HDR_RAW && hid == desc -> hid )
4755
- || (hid >= TFW_HTTP_HDR_RAW
4756
- && !__hdr_name_cmp (tgt , desc -> hdr )))
4757
- {
4758
- f_desc = desc ;
4759
- break ;
4760
- }
4761
- }
4762
- if (!f_desc )
4763
- goto def ;
4764
-
4765
- val = TFW_STR_CHUNK (f_desc -> hdr , 2 );
4766
- /*
4767
- * If this is a duplicate of already processed header,
4768
- * leave this duplicate as is (for transformation
4769
- * in-place) in case of appending operation, and remove
4770
- * it (by skipping) in case of substitution or deletion
4771
- * operations.
4772
- */
4773
- if (test_bit (k , mit -> found )) {
4774
- if (!val || !f_desc -> append )
4775
- continue ;
4776
-
4777
- mit -> bnd = first -> data ;
4778
- next -> s_hdr = * tgt ;
4779
- next -> op = TFW_H2_TRANS_INPLACE ;
4780
-
4781
- break ;
4782
- }
4783
-
4784
- __set_bit (k , mit -> found );
4785
-
4786
- /*
4787
- * If header configured with empty value, it should be
4788
- * removed from the response; so, just skip such header.
4789
- */
4790
- if (!val )
4791
- continue ;
4792
-
4793
- mit -> bnd = first -> data ;
4794
-
4795
- /*
4796
- * If the header configured for value appending,
4797
- * concatenate it with the target header in skb for
4798
- * subsequent in-place rewriting.
4799
- */
4800
- if (f_desc -> append ) {
4801
- TfwStr h_app = {
4802
- .chunks = (TfwStr []){
4803
- { .data = ", " , .len = 2 },
4804
- { .data = val -> data ,
4805
- .len = val -> len }
4806
- },
4807
- .len = val -> len + 2 ,
4808
- .nchunks = 2
4809
- };
4810
-
4811
- r = tfw_strcat (resp -> pool , tgt , & h_app );
4812
- if (unlikely (r ))
4813
- return r ;
4814
-
4815
- next -> s_hdr = * tgt ;
4816
- next -> op = TFW_H2_TRANS_INPLACE ;
4817
- break ;
4818
- }
4819
-
4820
- next -> s_hdr = * f_desc -> hdr ;
4821
- //next->op = TFW_H2_TRANS_SUB;
4822
- break ;
4823
-
4824
- def :
4825
- /*
4826
- * Remove 'Connection', 'Keep-Alive' headers and all hop-by-hop
4827
- * headers from the HTTP/2 response.
4828
- */
4829
- if (hid == TFW_HTTP_HDR_KEEP_ALIVE
4830
- || hid == TFW_HTTP_HDR_CONNECTION
4831
- || tgt -> flags & TFW_STR_HBH_HDR )
4832
- continue ;
4833
-
4834
- /*
4835
- * 'Server' header must be replaced; thus, remove the original
4836
- * header (and all its duplicates) skipping it here; the new
4837
- * header will be written later, during new headers' addition
4838
- * stage.
4839
- */
4840
- if (hid == TFW_HTTP_HDR_SERVER )
4841
- continue ;
4842
-
4843
- /*
4844
- * In general case the header should be transformed in-place
4845
- * from its original HTTP/1.1-representation in skb.
4846
- */
4847
- mit -> bnd = first -> data ;
4848
- next -> s_hdr = * tgt ;
4849
- next -> op = TFW_H2_TRANS_INPLACE ;
4850
-
4851
- break ;
4852
- }
4853
-
4854
- mit -> curr = i + 1 ;
4855
-
4856
- return 0 ;
4857
- }
4858
-
4859
4702
static int
4860
4703
__tfw_h2_make_frames (unsigned long len , char * data , TfwMsgIter * iter ,
4861
4704
unsigned long max_sz , const TfwStr * frame_hdr_str ,
@@ -5449,7 +5292,7 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
5449
5292
TfwHttpReq * req = resp -> req ;
5450
5293
TfwH2Ctx * ctx = tfw_h2_context (req -> conn );
5451
5294
TfwHttpTransIter * mit = & resp -> mit ;
5452
- TfwHttpRespCleanup cleanup ;
5295
+ TfwHttpRespCleanup cleanup = {} ;
5453
5296
TfwStr codings = {.data = * this_cpu_ptr (& g_te_buf ), .len = 0 };
5454
5297
const TfwHdrMods * h_mods = tfw_vhost_get_hdr_mods (req -> location ,
5455
5298
req -> vhost ,
@@ -5464,7 +5307,6 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
5464
5307
if (unlikely (!stream_id ))
5465
5308
goto out ;
5466
5309
5467
- memset (& cleanup , 0 , sizeof (TfwHttpRespCleanup ));
5468
5310
/*
5469
5311
* Accordingly to RFC 9113 8.2.2 connection-specific headers can't
5470
5312
* be used in HTTP/2.
@@ -5493,7 +5335,7 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
5493
5335
* Transform HTTP/1.1 headers into HTTP/2 form, in parallel with
5494
5336
* adjusting of particular headers.
5495
5337
*/
5496
- WARN_ON_ONCE (mit -> acc_len || mit -> curr );
5338
+ WARN_ON_ONCE (mit -> acc_len );
5497
5339
tfw_h2_msg_transform_setup (mit , resp -> msg .skb_head , true);
5498
5340
5499
5341
tfw_h2_msg_cutoff_headers (resp , & cleanup );
@@ -5504,14 +5346,11 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
5504
5346
*/
5505
5347
r = tfw_http_msg_setup_transform_pool (mit , resp -> pool );
5506
5348
if (unlikely (r ))
5507
- goto clean ;
5349
+ goto clean ;
5508
5350
5509
5351
r = tfw_h2_resp_status_write (resp , resp -> status , true, false);
5510
5352
if (unlikely (r ))
5511
- goto clean ;
5512
-
5513
- if (0 )
5514
- r = tfw_h2_resp_next_hdr (resp , h_mods );
5353
+ goto clean ;
5515
5354
5516
5355
r = tfw_h2_hpack_encode_headers (resp , h_mods );
5517
5356
if (unlikely (r ))
0 commit comments