fix(http1): try to drain connection buffer if user drops Body
This commit is contained in:
		| @@ -655,6 +655,20 @@ where | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /// If the read side can be cheaply drained, do so. Otherwise, close. | ||||
|     pub(super) fn poll_drain_or_close_read(&mut self, cx: &mut task::Context<'_>) { | ||||
|         let _ = self.poll_read_body(cx); | ||||
|  | ||||
|         // If still in Reading::Body, just give up | ||||
|         match self.state.reading { | ||||
|             Reading::Init | Reading::KeepAlive => { | ||||
|                 trace!("body drained"); | ||||
|                 return; | ||||
|             } | ||||
|             _ => self.close_read(), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub fn close_read(&mut self) { | ||||
|         self.state.close_read(); | ||||
|     } | ||||
|   | ||||
| @@ -186,9 +186,9 @@ where | ||||
|                         Poll::Ready(Err(_canceled)) => { | ||||
|                             // user doesn't care about the body | ||||
|                             // so we should stop reading | ||||
|                             trace!("body receiver dropped before eof, closing"); | ||||
|                             self.conn.close_read(); | ||||
|                             return Poll::Ready(Ok(())); | ||||
|                             trace!("body receiver dropped before eof, draining or closing"); | ||||
|                             self.conn.poll_drain_or_close_read(cx); | ||||
|                             continue; | ||||
|                         } | ||||
|                     } | ||||
|                     match self.conn.poll_read_body(cx) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user