Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c2b56c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm the winner of 'Hack the crap' !!! 💃
@skade can you review this commit. I want to know why until now we used 405 status instead of 404 ... I missed something ?
@dariocravero here we are!!!
@nesquena yeye!
c2b56c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow nice man! Actually got us working on newest http_router and all tests pass?
405 is when the request method is wrong right? is the request method wrong in those tests?
c2b56c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👯👯👯 Amazing!! Thanks! :)
On 405 vs 404, I think it shouldn't be a 405 since you're fetching it with the right method: GET, i.e., we're not trying to do a POST instead.
As for whether 404 is right on that case or not, I don't know, perhaps 406 fits better? From the MDN:
406 Not Acceptable
This response is sent when the web server, after performing server-driven content negotiation, doesn't find any content following the criteria given by the user agent.
Server-driven negotiation
In this kind of negotiation, the browser (or any other kind of agent) sends several HTTP headers along with the URI. These headers describe the preferred choice of the user. The server uses them as hints and an internal algorithm let it choose the best content to serve to the client. The algorithm is server-specific and not defined in the standard. See, for example, the Apache 2.2 negotiation algorithm.
The HTTP/1.1 standard gives an exhaustive list of the standard headers that may be used in a server-driven negotiation algorithm (Accept:, Accept-Charset:, Accept-Encoding:, Accept-Language:: and User-Agent:). Nevertheless it allows the server to use other aspects in its algorithm, either aspects outside the request itself or extension header fields, i.e., headers not defined in the HTTP/1.1 standard.
I know it's very specific but hey, we're already at it :P
Thoughts?
c2b56c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About 405, I don't know. I think it should be 404 in most cases (except wrong request method, but hey).
About 406, I know, we do already have support for it. The rule and behavior is explained in #441.
In short: Padrino will return 404 when a non-provided format is given in the url
(.format)
. If the format is parsed based on theACCEPT
-Header (true content-negotiation), it will return 406. That behaviour can be changed by settingtreat_format_as_accept
which treats theformat
parameter as if it was given through theACCEPT
header.