diff --git a/src/httpserver.h b/src/httpserver.h --- a/src/httpserver.h +++ b/src/httpserver.h @@ -84,19 +84,19 @@ enum RequestMethod { UNKNOWN, GET, POST, HEAD, PUT, OPTIONS }; /** Get requested URI */ - std::string GetURI(); + std::string GetURI() const; /** Get CService (address:ip) for the origin of the http request */ - CService GetPeer(); + CService GetPeer() const; /** Get request method */ - RequestMethod GetRequestMethod(); + RequestMethod GetRequestMethod() const; /** * Get the request header specified by hdr, or an empty string. * Return a pair (isPresent,string). */ - std::pair GetHeader(const std::string &hdr); + std::pair GetHeader(const std::string &hdr) const; /** * Read request body. diff --git a/src/httpserver.cpp b/src/httpserver.cpp --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -565,7 +565,8 @@ // evhttpd cleans up the request, as long as a reply was sent. } -std::pair HTTPRequest::GetHeader(const std::string &hdr) { +std::pair +HTTPRequest::GetHeader(const std::string &hdr) const { const struct evkeyvalq *headers = evhttp_request_get_input_headers(req); assert(headers); const char *val = evhttp_find_header(headers, hdr.c_str()); @@ -640,7 +641,7 @@ req = nullptr; } -CService HTTPRequest::GetPeer() { +CService HTTPRequest::GetPeer() const { evhttp_connection *con = evhttp_request_get_connection(req); CService peer; if (con) { @@ -653,11 +654,11 @@ return peer; } -std::string HTTPRequest::GetURI() { +std::string HTTPRequest::GetURI() const { return evhttp_request_get_uri(req); } -HTTPRequest::RequestMethod HTTPRequest::GetRequestMethod() { +HTTPRequest::RequestMethod HTTPRequest::GetRequestMethod() const { switch (evhttp_request_get_command(req)) { case EVHTTP_REQ_GET: return GET;