@@ -111,6 +111,8 @@ struct ChunkedHandler {
111111 */
112112 bool drop_chunked_trailers = false ;
113113
114+ bool strict_chunk_parsing = true ;
115+
114116 bool truncation = false ;
115117
116118 /* * The number of bytes to skip from the reader because they are not body bytes.
@@ -127,8 +129,10 @@ struct ChunkedHandler {
127129 int last_server_event = VC_EVENT_NONE;
128130
129131 // Chunked header size parsing info.
130- int running_sum = 0 ;
131- int num_digits = 0 ;
132+ int running_sum = 0 ;
133+ int num_digits = 0 ;
134+ int num_cr = 0 ;
135+ bool prev_is_cr = false ;
132136
133137 // / @name Output data.
134138 // @{
@@ -143,8 +147,8 @@ struct ChunkedHandler {
143147 // @}
144148 ChunkedHandler ();
145149
146- void init (IOBufferReader *buffer_in, HttpTunnelProducer *p, bool drop_chunked_trailers);
147- void init_by_action (IOBufferReader *buffer_in, Action action, bool drop_chunked_trailers);
150+ void init (IOBufferReader *buffer_in, HttpTunnelProducer *p, bool drop_chunked_trailers, bool strict_parsing );
151+ void init_by_action (IOBufferReader *buffer_in, Action action, bool drop_chunked_trailers, bool strict_parsing );
148152 void clear ();
149153
150154 // / Set the max chunk @a size.
@@ -389,6 +393,7 @@ class HttpTunnel : public Continuation
389393
390394 // / A named variable for the @a drop_chunked_trailers parameter to @a set_producer_chunking_action.
391395 static constexpr bool DROP_CHUNKED_TRAILERS = true ;
396+ static constexpr bool PARSE_CHUNK_STRICTLY = true ;
392397
393398 /* * Designate chunking behavior to the producer.
394399 *
@@ -399,9 +404,10 @@ class HttpTunnel : public Continuation
399404 * @param[in] drop_chunked_trailers If @c true, chunked trailers are filtered
400405 * out. Logically speaking, this is only applicable when proxying chunked
401406 * content, thus only when @a action is @c TCA_PASSTHRU_CHUNKED_CONTENT.
407+ * @param[in] parse_chunk_strictly If @c true, no parse error will be allowed
402408 */
403409 void set_producer_chunking_action (HttpTunnelProducer *p, int64_t skip_bytes, TunnelChunkingAction_t action,
404- bool drop_chunked_trailers);
410+ bool drop_chunked_trailers, bool parse_chunk_strictly );
405411 // / Set the maximum (preferred) chunk @a size of chunked output for @a producer.
406412 void set_producer_chunking_size (HttpTunnelProducer *producer, int64_t size);
407413
@@ -480,6 +486,9 @@ class HttpTunnel : public Continuation
480486 // / Corresponds to proxy.config.http.drop_chunked_trailers having a value of 1.
481487 bool http_drop_chunked_trailers = false ;
482488
489+ // / Corresponds to proxy.config.http.strict_chunk_parsing having a value of 1.
490+ bool http_strict_chunk_parsing = false ;
491+
483492 /* * The number of body bytes processed in this last execution of the tunnel.
484493 *
485494 * This accounting is used to determine how many bytes to copy into the body
0 commit comments