Skip to content

Commit

Permalink
http: Add const modifier to HTTPRequest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Aug 20, 2018
1 parent df660aa commit 18c49eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ HTTPRequest::~HTTPRequest()
// evhttpd cleans up the request, as long as a reply was sent.
}

std::pair<bool, std::string> HTTPRequest::GetHeader(const std::string& hdr)
std::pair<bool, std::string> HTTPRequest::GetHeader(const std::string& hdr) const
{
const struct evkeyvalq* headers = evhttp_request_get_input_headers(req);
assert(headers);
Expand Down Expand Up @@ -606,7 +606,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
req = nullptr; // transferred back to main thread
}

CService HTTPRequest::GetPeer()
CService HTTPRequest::GetPeer() const
{
evhttp_connection* con = evhttp_request_get_connection(req);
CService peer;
Expand All @@ -620,12 +620,12 @@ CService HTTPRequest::GetPeer()
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:
Expand Down
8 changes: 4 additions & 4 deletions src/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ class HTTPRequest

/** 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<bool, std::string> GetHeader(const std::string& hdr);
std::pair<bool, std::string> GetHeader(const std::string& hdr) const;

/**
* Read request body.
Expand Down

0 comments on commit 18c49eb

Please sign in to comment.