File tree 4 files changed +15
-2
lines changed
4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ impl Response {
47
47
version : version,
48
48
headers : headers,
49
49
url : url,
50
- message : message,
51
50
status_raw : raw_status,
52
- is_drained : false ,
51
+ is_drained : !message. has_body ( ) ,
52
+ message : message,
53
53
} )
54
54
}
55
55
Original file line number Diff line number Diff line change @@ -203,6 +203,13 @@ impl HttpMessage for Http11Message {
203
203
} )
204
204
}
205
205
206
+ fn has_body ( & self ) -> bool {
207
+ match self . reader {
208
+ Some ( EmptyReader ( ..) ) => false ,
209
+ _ => true
210
+ }
211
+ }
212
+
206
213
#[ cfg( feature = "timeouts" ) ]
207
214
#[ inline]
208
215
fn set_read_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > {
Original file line number Diff line number Diff line change @@ -400,6 +400,10 @@ impl<S> HttpMessage for Http2Message<S> where S: CloneableStream {
400
400
Ok ( head)
401
401
}
402
402
403
+ fn has_body ( & self ) -> bool {
404
+ true
405
+ }
406
+
403
407
#[ cfg( feature = "timeouts" ) ]
404
408
#[ inline]
405
409
fn set_read_timeout ( & self , _dur : Option < Duration > ) -> io:: Result < ( ) > {
Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ pub trait HttpMessage: Write + Read + Send + Any + Typeable + Debug {
72
72
fn set_write_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > ;
73
73
/// Closes the underlying HTTP connection.
74
74
fn close_connection ( & mut self ) -> :: Result < ( ) > ;
75
+ /// Returns whether the incoming message has a body.
76
+ fn has_body ( & self ) -> bool ;
75
77
}
76
78
77
79
impl HttpMessage {
You can’t perform that action at this time.
0 commit comments