@@ -59,6 +59,9 @@ pub(super) struct Recv {
5959
6060 /// If extended connect protocol is enabled.
6161 is_extended_connect_protocol_enabled : bool ,
62+
63+ /// Ignore the content length header and only stop when peer close stream
64+ ignore_content_length : bool ,
6265}
6366
6467#[ derive( Debug ) ]
@@ -107,6 +110,7 @@ impl Recv {
107110 refused : None ,
108111 is_push_enabled : config. local_push_enabled ,
109112 is_extended_connect_protocol_enabled : config. extended_connect_protocol_enabled ,
113+ ignore_content_length : config. ignore_content_length ,
110114 }
111115 }
112116
@@ -171,7 +175,7 @@ impl Recv {
171175 counts. inc_num_recv_streams ( stream) ;
172176 }
173177
174- if !stream. content_length . is_head ( ) {
178+ if !self . ignore_content_length && ! stream. content_length . is_head ( ) {
175179 use super :: stream:: ContentLength ;
176180 use http:: header;
177181
@@ -341,7 +345,7 @@ impl Recv {
341345 // Transition the state
342346 stream. state . recv_close ( ) ?;
343347
344- if stream. ensure_content_length_zero ( ) . is_err ( ) {
348+ if ! self . ignore_content_length && stream. ensure_content_length_zero ( ) . is_err ( ) {
345349 proto_err ! ( stream: "recv_trailers: content-length is not zero; stream={:?};" , stream. id) ;
346350 return Err ( Error :: library_reset ( stream. id , Reason :: PROTOCOL_ERROR ) ) ;
347351 }
@@ -616,7 +620,8 @@ impl Recv {
616620 return Err ( Error :: library_reset ( stream. id , Reason :: FLOW_CONTROL_ERROR ) ) ;
617621 }
618622
619- if stream. dec_content_length ( frame. payload ( ) . len ( ) ) . is_err ( ) {
623+ if !self . ignore_content_length && stream. dec_content_length ( frame. payload ( ) . len ( ) ) . is_err ( )
624+ {
620625 proto_err ! ( stream:
621626 "recv_data: content-length overflow; stream={:?}; len={:?}" ,
622627 stream. id,
@@ -626,7 +631,7 @@ impl Recv {
626631 }
627632
628633 if frame. is_end_stream ( ) {
629- if stream. ensure_content_length_zero ( ) . is_err ( ) {
634+ if ! self . ignore_content_length && stream. ensure_content_length_zero ( ) . is_err ( ) {
630635 proto_err ! ( stream:
631636 "recv_data: content-length underflow; stream={:?}; len={:?}" ,
632637 stream. id,
0 commit comments