-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Implement HTTP HEAD
method
#19
Comments
Actually i don't know why i missed that in here https://github.com/sdogruyol/kemal/blob/master/src/kemal/dsl.cr#L1 |
Yeah, I have explored the code and I have got a bit idea on where to make this change :-). I think it would be nice to support |
Yeah indeed 👍 |
You can implement and open a PR for it (with specs) |
That's great. I just checked Sinatra's |
Actually i'm not sure which one is better On Wednesday, 2 December 2015, Imran Latif notifications@github.com wrote:
|
I think we should support |
Yeah i'm actually surprised to hear that it works with all routes |
Only for |
Awesome. Thanks. 👍. |
I' am thinking that we could create a static site generator from |
Thanks for your comments. I also think that Crystal thus Kemal is pretty fast 👍 |
First I tried implementing this solution in such a way that it explicitly clears body and set `Content-Length` header to body's size. But for some reason, if I call the URL from cURL then `Content-Length` header was blank which defeats the very purpose of `HEAD` requests. I then later anticipated that since `HEAD` would be by-default implemented by `HTTP::Server` module, there is no need to explicit clears body and setting `Content-Length` but the way we have written our previous specs were returning body as well. We could have used some TestServer kind of thing but if we go to that route we explicitly need to test non-existent route which I thought would create some inconsistency among specs. Crystal has clearly written specs for HEAD requests to make sure body is not read for them. See crystal-lang/crystal@acd0b6afb5af438a30529c36b11b e7954336f23f. I decided to write simple specs which are easy to maintain in long-run. We are adding identical HEAD route for every GET route which will make HEAD requests available for all defined GET requests. kemalcr#19
@sdogruyol: I submitted a pull request. Please see my comment which describes the steps I went through. Thanks. |
Hey @ilatif currently i'm preparing a presentation for Crystal i'll take a look at your PR as soon as i can 👍 Thanks a lot |
Hi @sdogruyol, thanks for the prompt reply. Yeah sure, please take your time :-). Please share your presentation with me as well after you have presented it :-). I would love to see it :-). Thanks. |
First I tried implementing this solution in such a way that it explicitly clears body and set `Content-Length` header to body's size. But for some reason, if I call the URL from cURL then `Content-Length` header was blank which defeats the very purpose of `HEAD` requests. I then later anticipated that since `HEAD` would be by-default implemented by `HTTP::Server` module, there is no need to explicit clears body and setting `Content-Length` but the way we have written our previous specs were returning body as well. We could have used some TestServer kind of thing but if we go to that route we explicitly need to test non-existent route which I thought would create some inconsistency among specs. Crystal has clearly written specs for HEAD requests to make sure body is not read for them. See crystal-lang/crystal@acd0b6afb5af438a30529c36b11b e7954336f23f. I decided to write simple specs which are easy to maintain in long-run. We are adding identical HEAD route for every GET route which will make HEAD requests available for all defined GET requests. kemalcr#19 Added comment for code line which is adding HEAD routes for defined GET routes.
Closing this issue as this is implemented and merged. |
I' am thinking of implementing HTTP
HEAD
method to completekemal
's supported HTTP methods set.The text was updated successfully, but these errors were encountered: