Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closed state to HTTP::Server::Response #6477

Merged

Conversation

straight-shoota
Copy link
Member

Fixes #6465

@straight-shoota straight-shoota force-pushed the jm/fix/http-response-close branch from 998a533 to 82dc655 Compare August 2, 2018 08:22
def closed?
@closed
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be checked in unbuffered_write?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IO::Buffered#write already calls check_open. This is ensured with the expect_raises expectation.

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closed = false in reset

@@ -154,6 +159,7 @@ class HTTP::Server
@sync = false
@flush_on_newline = false
@chunked = false
@closed = false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asterite This is in #reset. I'm not sure how useful this is, because when a request is closed, at least the headers has already been written to the underlying IO. This effectively can't be reset because the response is already sent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool. Reset is useful, can't remember now why, but response is reused for keep alive, check request processor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, RequestProcessor resets the response to avoid allocating a new instance for each iteration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment about this.

Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @straight-shoota 👍

@sdogruyol sdogruyol added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Aug 2, 2018
@sdogruyol sdogruyol merged commit d454f69 into crystal-lang:master Aug 2, 2018
@sdogruyol sdogruyol added this to the 0.26.0 milestone Aug 2, 2018
@straight-shoota straight-shoota deleted the jm/fix/http-response-close branch August 2, 2018 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants