@@ -187,12 +187,15 @@ __tfw_dbg_dump_ce(const TfwCacheEntry *ce)
187
187
* String header for cache entries used for TfwStr serialization.
188
188
*
189
189
* @flags - TFW_CSTR_DUPLICATE and TFW_CSTR_HPACK_IDX or zero;
190
- * @len - string length or number of duplicates;
190
+ * @name_len - Header name length. Used for raw headers;
191
+ * @name_len_sz - HPACK int size of @name_len;
191
192
* @idx - HPACK static index or index of special header;
192
193
*/
193
194
typedef struct {
194
195
unsigned long flags : 8 ,
195
- len : 48 ,
196
+ name_len : 11 ,
197
+ name_len_sz : 2 ,
198
+ len : 35 ,
196
199
idx : 8 ;
197
200
} TfwCStr ;
198
201
@@ -766,12 +769,16 @@ tfw_cache_set_status(TDB *db, TfwCacheEntry *ce, TfwHttpResp *resp,
766
769
}
767
770
768
771
static bool
769
- tfw_cache_skip_hdr (TfwCStr * str , char * p , const TfwHdrMods * h_mods )
772
+ tfw_cache_skip_hdr (const TfwCStr * str , char * p , const TfwHdrMods * h_mods )
770
773
{
771
- unsigned int len , i ;
774
+ unsigned int i ;
772
775
const TfwHdrModsDesc * desc ;
773
- const char * last = p + str -> len ;
774
- TfwStr hdr = {};
776
+ /*
777
+ * Move to beggining of the header name. Skip first byte of HPACK
778
+ * string and name length size.
779
+ */
780
+ TfwStr hdr = { .data = p + str -> name_len_sz + 1 ,
781
+ .len = str -> name_len };
775
782
776
783
/* Fast path for special headers */
777
784
if (str -> flags & TFW_CSTR_SPEC_IDX ) {
@@ -789,22 +796,6 @@ tfw_cache_skip_hdr(TfwCStr *str, char *p, const TfwHdrMods *h_mods)
789
796
return test_bit (hpack_idx , h_mods -> s_tbl );
790
797
}
791
798
792
- p ++ ;
793
- len = * p ++ & 0x7F ;
794
-
795
- if (unlikely (len == 0 ))
796
- return true;
797
-
798
- if (unlikely (len == 0x7F )
799
- && unlikely (tfw_hpack_decode_int (& p , last , & len )))
800
- {
801
- T_WARN ("Error while decoding hpack int" );
802
- return true;
803
- }
804
-
805
- hdr .data = p ;
806
- hdr .len = len ;
807
-
808
799
for (i = h_mods -> spec_num ; i < h_mods -> sz ; ++ i ) {
809
800
int cmplen ;
810
801
char * mod_hdr_name ;
@@ -1234,11 +1225,13 @@ do { \
1234
1225
ce->hdr_len += TFW_CSTR_HDRLEN; \
1235
1226
} while (0)
1236
1227
1237
- #define CSTR_WRITE_HDR (f , l , i ) \
1238
- do { \
1239
- cs->flags = f; \
1240
- cs->len = l; \
1241
- cs->idx = i; \
1228
+ #define CSTR_WRITE_HDR (f , l , nl , i ) \
1229
+ do { \
1230
+ cs->flags = f; \
1231
+ cs->len = l; \
1232
+ cs->name_len = nl; \
1233
+ cs->name_len_sz = tfw_hpack_int_size(nl, 0x7f); \
1234
+ cs->idx = i; \
1242
1235
} while (0)
1243
1236
1244
1237
/**
@@ -1574,9 +1567,9 @@ tfw_cache_h2_copy_hdr(TfwCacheEntry *ce, TfwHttpResp *resp, int hid, char **p,
1574
1567
CSTR_MOVE_HDR ();
1575
1568
if (hid >= TFW_HTTP_HDR_REGULAR && hid < TFW_HTTP_HDR_RAW )
1576
1569
CSTR_WRITE_HDR (TFW_CSTR_SPEC_IDX | TFW_CSTR_DUPLICATE ,
1577
- hdr -> nchunks , hid );
1570
+ hdr -> nchunks , 0 , hid );
1578
1571
else
1579
- CSTR_WRITE_HDR (TFW_CSTR_DUPLICATE , hdr -> nchunks ,
1572
+ CSTR_WRITE_HDR (TFW_CSTR_DUPLICATE , hdr -> nchunks , 0 ,
1580
1573
st_index );
1581
1574
}
1582
1575
@@ -1619,9 +1612,10 @@ tfw_cache_h2_copy_hdr(TfwCacheEntry *ce, TfwHttpResp *resp, int hid, char **p,
1619
1612
1620
1613
if (hid >= TFW_HTTP_HDR_REGULAR && hid < TFW_HTTP_HDR_RAW )
1621
1614
CSTR_WRITE_HDR (TFW_CSTR_SPEC_IDX ,
1622
- ce -> hdr_len - prev_len , hid );
1615
+ ce -> hdr_len - prev_len , 0 , hid );
1623
1616
else
1624
- CSTR_WRITE_HDR (0 , ce -> hdr_len - prev_len , st_index );
1617
+ CSTR_WRITE_HDR (0 , ce -> hdr_len - prev_len , s_nm .len ,
1618
+ st_index );
1625
1619
}
1626
1620
1627
1621
T_DBG3 ("%s: p=[%p], trec=[%p], ce->hdr_len='%u', tot_len='%zu'\n" ,
@@ -1672,7 +1666,7 @@ tfw_cache_h2_add_hdr(TfwCacheEntry *ce, char **p, TdbVRec **trec,
1672
1666
if (tfw_cache_h2_copy_str (& ce -> hdr_len , p , trec , val , tot_len ))
1673
1667
return - ENOMEM ;
1674
1668
1675
- CSTR_WRITE_HDR (0 , ce -> hdr_len - prev_len - TFW_CSTR_HDRLEN , st_idx );
1669
+ CSTR_WRITE_HDR (0 , ce -> hdr_len - prev_len - TFW_CSTR_HDRLEN , 0 , st_idx );
1676
1670
1677
1671
return ce -> hdr_len - prev_len ;
1678
1672
}
0 commit comments