Skip to content

Commit

Permalink
Drop the request reader earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Dec 6, 2016
1 parent 1dc2c8e commit 091ce80
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ impl Request {
fn respond_impl<R>(&mut self, response: Response<R>) -> Result<(), IoError>
where R: Read
{
// Droping the request reader now so that further requests can start processing immediately.
self.data_reader = None;

let mut writer = self.into_writer_impl();

let do_not_send_body = self.method == Method::Head;
Expand Down Expand Up @@ -396,6 +399,9 @@ impl fmt::Debug for Request {

impl Drop for Request {
fn drop(&mut self) {
// Droping the request reader now so that further requests can start processing immediately.
self.data_reader = None;

if self.response_writer.is_some() {
let response = Response::empty(500);
let _ = self.respond_impl(response); // ignoring any potential error
Expand Down

0 comments on commit 091ce80

Please sign in to comment.