drogon icon indicating copy to clipboard operation
drogon copied to clipboard

Options return for path /*

Open mike-5345 opened this issue 9 months ago • 1 comments

curious why this is included and is hardcoded and not configurable? what is the reason for this?

if (req->method() == Options && (req->path() == "*" || req->path() == "/*"))
    {
        auto resp = HttpResponse::newHttpResponse();
        resp->setContentTypeCode(ContentType::CT_TEXT_PLAIN);
        resp->addHeader("Allow", "GET,HEAD,POST,PUT,DELETE,OPTIONS,PATCH");
        resp->setExpiredTime(0);
        callback(resp);
        return;
    }

where the code can be found: https://github.com/drogonframework/drogon/blob/59cd4366c75c8f15c011f476f4850b97086f5de5/lib/src/HttpServer.cc#L419

mike-5345 avatar Apr 09 '25 00:04 mike-5345

An OPTIONS request with a path of * (i.e. OPTIONS * HTTP/1.1) is a server-wide request. It is used by the client to ask:

"What HTTP methods does this server support, regardless of a specific resource?"

This is defined in RFC 9110, Section 9.3.7.

an-tao avatar Apr 09 '25 01:04 an-tao