-
Notifications
You must be signed in to change notification settings - Fork 645
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
head request seems to be waiting for body #2322
Comments
You have to tell the library that you don't expect a body, this is explained here: |
Hi Vinnie, First case, is the HEAD method, second one is the 304 response. IMHO delegating this logic to boost beast's user does more harm than good, as the HTML spec is quite strict and stable as to body presence in the response. |
But that's not correct. Beast understands perfectly that a 304 has no body:
The problem with a response to HEAD is that Beast has no way to know that it is receiving a response to the HEAD request. The user has to inform the library - there is no other way around. All the other response codes should work, i.e. Beast will know that they do not have the body (see code above). You will note that every HTTP library is like this. For example, see here: |
Ehm... sorry... I missed the HTTP 304 stuff. First of all.. using the async_write overload with "parser" argument and calling the skip() method on the parser does the trick indeed, and the whole thing boils down to async_write with "embedded parser" incompatibilty with HEAD requests. async_write of course knows that it's making an HEAD request, I'm pretty sure the code could be modified to automatically configure the parser (not that I could do it ;-) Possibly this missing bit of logic has not been written for a design choice... say separation of concerns or whatever. Am i really that wrong? |
We do have internal discussions on design improvements that could be made. We’re not entirely happy with the relationship between parser and body_type, for example. So the door is certainly open if you have design changes to explore. In response to the above: I think our view that setting a flag on the parser (I am not expecting a body) and asking the parser to skip the body after receiving the header, logically amount to the same thing. Do we agree on that? |
Hi madmongo, I can talk as a user, and not as a library developer, which I'm not (I wish I were). If you ask me, I would find it much more reasonable to have an "I do it all" API (read_async HEAD aware) and two lower level APIs read_header, read_body: it would be a bit more obvious that it is up to the user to skip the body. Lastly, as I guess that 99% of people creates a "connection" class with a request, a response, a buffer, and a parser, I'd try to reduce headache and push more with "moves". Definitely for the request. Probably for the response. Not sure for the parser, as it is virtual (is it really needed?) In my dreams I would code this: http::read_async(std::move(request), [](error_code, response&& r) { or for more elaborate use cases: http::read_async(std::move(request), parser_options, [](error_code, response&& r) { Again, I'm not a library writer, not a template guy, so it is really possible I'm talking complete nonsense. |
None of this is nonsense. I think our view is that users would love an API that looks a lot like python’s requests library. |
Well my use case right now is opening a few connections and stress test media origin servers. So what is missing... is what you know is missing: high level.
And let me add:
I suppose that taking inspiration from a python library is a good idea (I see that requests is the stanrdard-the facto): API friendliness is very typical over there. Let me know if and how I can be any help. |
I have some good news for you.
If I published an absolutely minimal subject-to-change library that you could experiment with and provide feedback, would you be happy to act as a lab rat user? |
Go ahead |
OK, I'm actually on holiday at the moment, so I'll start while my wife isn't looking. She'll get mad with me if she catches me working ;-) |
Yes you're right about that. Beast is intended to be the low level building block upon which these higher abstractions are written. A higher level library would handle the entire HEAD process from request to response for you, hiding the detail of knowing that the body is not expected. |
This issue has been open for a while with no activity, has it been resolved? |
head request takes ages.
I might be wrong, but I suppose that async_read is waiting for a body, which of course is not there.
Simple workaround might be using async_read_header... but in my opinion async_read should work anyway
Version of Beast
306
Steps necessary to reproduce the problem
All relevant compiler information
Visual Studio 2019, building in Debug / 32 bit. Yes. 32 bit.
The text was updated successfully, but these errors were encountered: