Decoupled RequestContext from MHD_Connection

This will simplify testing of Response utilities.
This commit is contained in:
Veloman Yunkan
2023-12-05 17:48:10 +04:00
parent af228bf45f
commit aee6c23082
4 changed files with 47 additions and 23 deletions

View File

@ -8,9 +8,11 @@ namespace
using namespace kiwix;
RequestContext makeHttpGetRequest(const std::string& url)
RequestContext makeHttpGetRequest(const std::string& url,
const RequestContext::NameValuePairs& headers,
const RequestContext::NameValuePairs& queryArgs)
{
return RequestContext(nullptr, "", url, "GET", "1.1");
return RequestContext("", url, "GET", "1.1", headers, queryArgs);
}
std::string getResponseContent(const ContentResponseBlueprint& crb)
@ -23,7 +25,7 @@ std::string getResponseContent(const ContentResponseBlueprint& crb)
TEST(HTTPErrorResponse, shouldBeInEnglishByDefault) {
const RequestContext req = makeHttpGetRequest("/asdf");
const RequestContext req = makeHttpGetRequest("/asdf", {}, {});
HTTPErrorResponse errResp(req, MHD_HTTP_NOT_FOUND,
"404-page-title",
"404-page-heading",