@@ -90,28 +90,24 @@ enum HeaderState {
9090};
9191
9292static void
93- update_object_size (TSHttpTxn txnp , int64_t size, Config &config)
93+ update_object_size (std::string_view const url , int64_t size, Config &config)
9494{
95- int urllen = 0 ;
96- char *urlstr = TSHttpTxnEffectiveUrlStringGet (txnp, &urllen);
97- if (urlstr != nullptr ) {
98- if (size <= 0 ) {
99- DEBUG_LOG (" Ignoring invalid content length for %.*s: %" PRId64, urllen, urlstr, size);
100- TSfree (urlstr);
101- return ;
102- }
95+ if (url.empty ()) {
96+ ERROR_LOG (" Could not get URL from transaction." );
97+ return ;
98+ }
10399
104- if (static_cast <uint64_t >(size) >= config.m_min_size_to_slice ) {
105- config.sizeCacheAdd ({urlstr, static_cast <size_t >(urllen)}, static_cast <uint64_t >(size));
106- TSStatIntIncrement (config.stat_TP , 1 );
107- } else {
108- config.sizeCacheRemove ({urlstr, static_cast <size_t >(urllen)});
109- TSStatIntIncrement (config.stat_FP , 1 );
110- }
100+ if (size <= 0 ) {
101+ DEBUG_LOG (" Ignoring invalid content length for %.*s: %" PRId64, static_cast <int >(url.size ()), url.data (), size);
102+ return ;
103+ }
111104
112- TSfree (urlstr);
105+ if (static_cast <uint64_t >(size) >= config.m_min_size_to_slice ) {
106+ config.sizeCacheAdd (url, static_cast <uint64_t >(size));
107+ TSStatIntIncrement (config.stat_TP , 1 );
113108 } else {
114- ERROR_LOG (" Could not get URL from transaction." );
109+ config.sizeCacheRemove (url);
110+ TSStatIntIncrement (config.stat_FP , 1 );
115111 }
116112}
117113
@@ -151,7 +147,7 @@ handleFirstServerHeader(Data *const data, TSCont const contp)
151147 }
152148 DEBUG_LOG (" Passthru bytes: header: %" PRId64 " body: %" PRId64, hlen, clen);
153149 if (clen != INT64_MAX ) {
154- update_object_size (data->m_txnp , clen, *data->m_config );
150+ update_object_size (data->m_effective_url , clen, *data->m_config );
155151 TSVIONBytesSet (output_vio, hlen + clen);
156152 } else {
157153 TSVIONBytesSet (output_vio, clen);
@@ -171,7 +167,7 @@ handleFirstServerHeader(Data *const data, TSCont const contp)
171167 return HeaderState::Fail;
172168 }
173169
174- update_object_size (data->m_txnp , blockcr.m_length , *data->m_config );
170+ update_object_size (data->m_effective_url , blockcr.m_length , *data->m_config );
175171
176172 // set the resource content length from block response
177173 data->m_contentlen = blockcr.m_length ;
0 commit comments