define HTTP request methods at module level outside of class

This is a refactor to prepare for matching the API of HTTPRequest
definitions in both namespaces http_bitcoin and http_libevent. In
particular, to provide a consistent return type for GetRequestMethod()
in both classes.
This commit is contained in:
Matthew Zipkin
2024-12-11 13:21:31 -05:00
parent 7ee7df988e
commit dd11b5e01b
5 changed files with 45 additions and 36 deletions

View File

@@ -45,6 +45,14 @@ struct evhttp_request;
struct event_base;
class CService;
enum class HTTPRequestMethod {
UNKNOWN,
GET,
POST,
HEAD,
PUT
};
namespace http_libevent {
class HTTPRequest;
@@ -96,14 +104,6 @@ public:
explicit HTTPRequest(struct evhttp_request* req, const util::SignalInterrupt& interrupt, bool replySent = false);
~HTTPRequest();
enum RequestMethod {
UNKNOWN,
GET,
POST,
HEAD,
PUT
};
/** Get requested URI.
*/
std::string GetURI() const;
@@ -114,7 +114,7 @@ public:
/** Get request method.
*/
RequestMethod GetRequestMethod() const;
HTTPRequestMethod GetRequestMethod() const;
/** Get the query parameter value from request uri for a specified key, or std::nullopt if the
* key is not found.
@@ -287,7 +287,7 @@ class HTTPRemoteClient;
class HTTPRequest
{
public:
std::string m_method;
HTTPRequestMethod m_method;
std::string m_target;
HTTPVersion m_version;
HTTPHeaders m_headers;