http: enclose libevent-dependent code in a namespace

This commit is a no-op to isolate HTTP methods and objects that
depend on libevent. Following commits will add replacement objects
and methods in a new namespace for testing and review before
switching over the server.
This commit is contained in:
Matthew Zipkin
2024-09-30 12:28:54 -04:00
parent 5aa3629b48
commit 89c54ae4cb
8 changed files with 25 additions and 5 deletions

View File

@@ -46,6 +46,7 @@
#include <support/events.h>
using common::InvalidPortErrMsg;
using http_libevent::HTTPRequest;
/** Maximum size of http request (request line + headers) */
static const size_t MAX_HEADERS_SIZE = 8192;
@@ -381,6 +382,7 @@ static void libevent_log_cb(int severity, const char *msg)
}
}
namespace http_libevent {
bool InitHTTPServer(const util::SignalInterrupt& interrupt)
{
if (!InitHTTPAllowList())
@@ -497,6 +499,7 @@ struct event_base* EventBase()
{
return eventBase;
}
} // namespace http_libevent
static void httpevent_callback_fn(evutil_socket_t, short, void* data)
{
@@ -524,6 +527,8 @@ void HTTPEvent::trigger(struct timeval* tv)
else
evtimer_add(ev, tv); // trigger after timeval passed
}
namespace http_libevent {
HTTPRequest::HTTPRequest(struct evhttp_request* _req, const util::SignalInterrupt& interrupt, bool _replySent)
: req(_req), m_interrupt(interrupt), replySent(_replySent)
{
@@ -686,6 +691,7 @@ std::optional<std::string> GetQueryParameterFromUri(const char* uri, const std::
return result;
}
} // namespace http_libevent
void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler)
{