Skip to content

Commit

Permalink
Merge pull request #125 from tomaka/reader-early-drop
Browse files Browse the repository at this point in the history
Drop the request reader earlier
  • Loading branch information
frewsxcv committed Dec 7, 2016
2 parents 320dab1 + 091ce80 commit 4e7c504
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 @@ -365,6 +365,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 @@ -393,6 +396,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 4e7c504

Please sign in to comment.