mirror of https://github.com/kiwix/libkiwix.git
Retired HTTP500Response::generateResponseObject()
... whereupon `ContentResponseBlueprint::generateResponseObject()` (and `ContentResponseBlueprint` as a whole) no longer needs to be polymorphic.
This commit is contained in:
parent
797f4c432c
commit
54191bcfab
|
@ -234,14 +234,6 @@ HTTP500Response::HTTP500Response(const RequestContext& request)
|
|||
*this += nonParameterizedMessage("500-page-text");
|
||||
}
|
||||
|
||||
std::unique_ptr<ContentResponse> HTTP500Response::generateResponseObject() const
|
||||
{
|
||||
const std::string mimeType = "text/html;charset=utf-8";
|
||||
auto r = ContentResponse::build(m_template, m_data, mimeType);
|
||||
r->set_code(m_httpStatusCode);
|
||||
return r;
|
||||
}
|
||||
|
||||
std::unique_ptr<Response> Response::build_416(size_t resourceLength)
|
||||
{
|
||||
auto response = Response::build();
|
||||
|
|
|
@ -128,20 +128,16 @@ public: // functions
|
|||
, m_template(templateStr)
|
||||
{}
|
||||
|
||||
virtual ~ContentResponseBlueprint() = default;
|
||||
|
||||
operator std::unique_ptr<Response>() const
|
||||
{
|
||||
return generateResponseObject();
|
||||
}
|
||||
|
||||
std::unique_ptr<ContentResponse> generateResponseObject() const;
|
||||
|
||||
protected: // functions
|
||||
std::string getMessage(const std::string& msgId) const;
|
||||
|
||||
public:
|
||||
virtual std::unique_ptr<ContentResponse> generateResponseObject() const;
|
||||
|
||||
public: //data
|
||||
const RequestContext& m_request;
|
||||
const int m_httpStatusCode;
|
||||
|
@ -180,11 +176,6 @@ struct HTTP400Response : HTTPErrorResponse
|
|||
struct HTTP500Response : HTTPErrorResponse
|
||||
{
|
||||
explicit HTTP500Response(const RequestContext& request);
|
||||
|
||||
private: // overrides
|
||||
// generateResponseObject() is overriden in order to produce a minimal
|
||||
// response without any need for additional resources from the server
|
||||
std::unique_ptr<ContentResponse> generateResponseObject() const override;
|
||||
};
|
||||
|
||||
class ItemResponse : public Response {
|
||||
|
|
|
@ -1054,7 +1054,7 @@ TEST_F(ServerTest, 500)
|
|||
const auto r = zfs1_->GET("/ROOT%23%3F/content/poor/A/redirect_loop.html");
|
||||
EXPECT_EQ(r->status, 500);
|
||||
EXPECT_EQ(r->body, expectedBody);
|
||||
EXPECT_EQ(r->get_header_value("Content-Type"), "text/html;charset=utf-8");
|
||||
EXPECT_EQ(r->get_header_value("Content-Type"), "text/html; charset=utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue