HTTP: Error message is sent as the payload as well.
This shows the error message in the browsers. Before, the browsers would display just a blank page.
This commit is contained in:
parent
3b49a1d250
commit
d40078d163
|
@ -38,7 +38,9 @@ cHTTPConnection::~cHTTPConnection()
|
||||||
|
|
||||||
void cHTTPConnection::SendStatusAndReason(int a_StatusCode, const AString & a_Response)
|
void cHTTPConnection::SendStatusAndReason(int a_StatusCode, const AString & a_Response)
|
||||||
{
|
{
|
||||||
SendData(Printf("%d %s\r\nContent-Length: 0\r\n\r\n", a_StatusCode, a_Response.c_str()));
|
SendData(Printf("HTTP/1.1 %d %s\r\n", a_StatusCode, a_Response.c_str()));
|
||||||
|
SendData(Printf("Content-Length: %u\r\n\r\n", static_cast<unsigned>(a_Response.size())));
|
||||||
|
SendData(a_Response.data(), a_Response.size());
|
||||||
m_State = wcsRecvHeaders;
|
m_State = wcsRecvHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ public:
|
||||||
cHTTPConnection(cHTTPServer & a_HTTPServer);
|
cHTTPConnection(cHTTPServer & a_HTTPServer);
|
||||||
virtual ~cHTTPConnection();
|
virtual ~cHTTPConnection();
|
||||||
|
|
||||||
/** Sends HTTP status code together with a_Reason (used for HTTP errors) */
|
/** Sends HTTP status code together with a_Reason (used for HTTP errors).
|
||||||
|
Sends the a_Reason as the body as well, so that browsers display it. */
|
||||||
void SendStatusAndReason(int a_StatusCode, const AString & a_Reason);
|
void SendStatusAndReason(int a_StatusCode, const AString & a_Reason);
|
||||||
|
|
||||||
/** Sends the "401 unauthorized" reply together with instructions on authorizing, using the specified realm */
|
/** Sends the "401 unauthorized" reply together with instructions on authorizing, using the specified realm */
|
||||||
|
|
Loading…
Reference in New Issue