Closed Greisby closed 1 year ago
Well, I found in HttpServer.cc the following:
bool isHeadMethod = (req->method() == Head);
if (isHeadMethod)
{
req->setMethod(Get);
}
and then a lots of references to isHeadMethod, probably to drop the body. I have no idea of the implications of removing this setMethod(Get). Perhaps that the safest solution would be to add an extra property in HttpRequestImpl.h:
class HttpRequestImpl : public HttpRequest
{
bool isHead() const { return head_; }
void setMethod(const HttpMethod method) override
{
method_ = method;
head_ |= (method == Head);
}
private:
bool head_{ false };
I made a proposal in PR #1743
Description of the bug In the controller, there is no way to add a method for drogon::HttpMethod::Head, neither to know that a drogon::Get method was called from a HEAD request.
To Reproduce Example:
The doGet() method is systematically called, whether the request method is GET or HEAD, and the request->method() is also always drogon::Get It is therefore impossible to know if a GET or HEAD request was done.
Expected behavior: Be able do differentiate between them, to avoid the overhead of generating a body that is then dropped.
Proposed solution: Either:
Desktop: