@@ -59,6 +59,9 @@ pub(super) struct Recv {
59
59
60
60
/// If extended connect protocol is enabled.
61
61
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 ,
62
65
}
63
66
64
67
#[ derive( Debug ) ]
@@ -107,6 +110,7 @@ impl Recv {
107
110
refused : None ,
108
111
is_push_enabled : config. local_push_enabled ,
109
112
is_extended_connect_protocol_enabled : config. extended_connect_protocol_enabled ,
113
+ ignore_content_length : config. ignore_content_length ,
110
114
}
111
115
}
112
116
@@ -171,7 +175,7 @@ impl Recv {
171
175
counts. inc_num_recv_streams ( stream) ;
172
176
}
173
177
174
- if !stream. content_length . is_head ( ) {
178
+ if !self . ignore_content_length && ! stream. content_length . is_head ( ) {
175
179
use super :: stream:: ContentLength ;
176
180
use http:: header;
177
181
@@ -341,7 +345,7 @@ impl Recv {
341
345
// Transition the state
342
346
stream. state . recv_close ( ) ?;
343
347
344
- if stream. ensure_content_length_zero ( ) . is_err ( ) {
348
+ if ! self . ignore_content_length && stream. ensure_content_length_zero ( ) . is_err ( ) {
345
349
proto_err ! ( stream: "recv_trailers: content-length is not zero; stream={:?};" , stream. id) ;
346
350
return Err ( Error :: library_reset ( stream. id , Reason :: PROTOCOL_ERROR ) ) ;
347
351
}
@@ -616,7 +620,8 @@ impl Recv {
616
620
return Err ( Error :: library_reset ( stream. id , Reason :: FLOW_CONTROL_ERROR ) ) ;
617
621
}
618
622
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
+ {
620
625
proto_err ! ( stream:
621
626
"recv_data: content-length overflow; stream={:?}; len={:?}" ,
622
627
stream. id,
@@ -626,7 +631,7 @@ impl Recv {
626
631
}
627
632
628
633
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 ( ) {
630
635
proto_err ! ( stream:
631
636
"recv_data: content-length underflow; stream={:?}; len={:?}" ,
632
637
stream. id,
0 commit comments