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

Response#reset leaves the status message untouched #13076

Closed
ya55en opened this issue Feb 15, 2023 · 2 comments · Fixed by #13282
Closed

Response#reset leaves the status message untouched #13076

ya55en opened this issue Feb 15, 2023 · 2 comments · Fixed by #13282
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking

Comments

@ya55en
Copy link

ya55en commented Feb 15, 2023

Bug Report

It seems HTTP::Server::Response are reused and re-set on reuse, however, it seems the status message is left untouched on #reset:

require "http"

response = HTTP::Server::Response.new(IO::Memory.new)
puts "#{response.status_code} #{response.status_message}"

response.status_message = "Foo Bar"
response.reset
puts "#{response.status_code} #{response.status_message}"

This yields:

200 OK
200 Foo Bar

and I would expect just a "200 OK" twice, because of the #reset call. (Or do I miss something?)

Environment:

$ crystal --version
Crystal 1.7.2 [29f9ac503] (2023-01-23)

LLVM: 13.0.1
Default target: x86_64-unknown-linux-gnu
@ya55en ya55en added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 15, 2023
@ya55en ya55en changed the title HTTP::Server::Response#reset leaves the status message untouched Response#reset leaves the status message untouched Feb 15, 2023
@etra0
Copy link
Contributor

etra0 commented Mar 24, 2023

I wonder, this would be a fairly easy thing to fix but yet the Response#reset is hidden from the docs. Any reason for that?

@Blacksmoke16
Copy link
Member

It's more of an implementation detail than something you should consider calling yourself within an HTTP::Handler or something. It's probably still worth fixing, but I'd be curious if you can actually reproduce this bug without calling it directly.

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:networking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants