Add test for issue #2444

A WWW-Authenticate header must be present in the 401 response to make clients
know that they can authenticate, and how.
This commit is contained in:
Jack Grigg
2017-07-12 16:34:07 -05:00
parent 5df11e9d8e
commit 689264bbff
3 changed files with 72 additions and 6 deletions

View File

@@ -56,11 +56,14 @@ class HTTPRequest
{
private:
struct evhttp_request* req;
// For test access
protected:
bool replySent;
public:
HTTPRequest(struct evhttp_request* req);
~HTTPRequest();
virtual ~HTTPRequest();
enum RequestMethod {
UNKNOWN,
@@ -76,17 +79,17 @@ public:
/** Get CService (address:ip) for the origin of the http request.
*/
CService GetPeer();
virtual CService GetPeer();
/** Get request method.
*/
RequestMethod GetRequestMethod();
virtual RequestMethod GetRequestMethod();
/**
* Get the request header specified by hdr, or an empty string.
* Return an pair (isPresent,string).
*/
std::pair<bool, std::string> GetHeader(const std::string& hdr);
virtual std::pair<bool, std::string> GetHeader(const std::string& hdr);
/**
* Read request body.
@@ -101,7 +104,7 @@ public:
*
* @note call this before calling WriteErrorReply or Reply.
*/
void WriteHeader(const std::string& hdr, const std::string& value);
virtual void WriteHeader(const std::string& hdr, const std::string& value);
/**
* Write HTTP reply.
@@ -111,7 +114,7 @@ public:
* @note Can be called only once. As this will give the request back to the
* main thread, do not call any other HTTPRequest methods after calling this.
*/
void WriteReply(int nStatus, const std::string& strReply = "");
virtual void WriteReply(int nStatus, const std::string& strReply = "");
};
/** Event handler closure.