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

Http::Response.build passing nil status code to HTTP::Response.new #64

Open
trapped opened this issue Nov 7, 2015 · 0 comments
Open

Comments

@trapped
Copy link

trapped commented Nov 7, 2015

Here the status code is allowed to be nil, causing the compiler to complain:

in ./libs/amethyst/amethyst/base/handler.cr:12: instantiating 'Amethyst::Http::Response#build()'
        response.build
                 ^~~~~
in ./libs/amethyst/amethyst/http/response.cr:23: instantiating 'HTTP::Response:Class#new((Nil | Int32), String, HTTP::Headers)'
        return HTTP::Response.new(@status, @body, headers = @headers)
                              ^~~
instantiating 'HTTP::Response#initialize((Nil | Int32), String, HTTP::Headers, Nil, String, Nil)'
in /Users/giorgio/Documents/crystal/src/http/response.cr:14: instantiating 'HTTP::Response:Class#mandatory_body?((Nil | Int32))'
    if Response.mandatory_body?(@status_code)
                ^~~~~~~~~~~~~~~
in /Users/giorgio/Documents/crystal/src/http/response.cr:77: undefined method '/' for Nil (compile-time type is (Nil | Int32))
    !(status_code / 100 == 1 || status_code == 204 || status_code == 304)

Either Http::Response.new should not allow a nil status code, or Http::Response.build should check for that and use a "default" one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant