Purpose: Send a 404 not found message to browser. This message will be a default message if the global variable g_WebPageNotFound is not set within an application.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzHttpEvent::SendNotFound | (hzUrl&,) |
Declared in file: hzHttpServer.h
Defined in file : hzHttpServer.cpp
Function Logic:
Function body:
hzEcode hzHttpEvent::SendNotFound (hzUrl& url)
{
// Purpose: Send a 404 not found message to browser. This message will be a default message if the global variable g_WebPageNotFound is not
// set within an application.
//
// Arguments: 1) url The resource (page) that was not found
//
// Returns: E_WRITEFAIL If the error message could not be sent
// E_OK If the operation was successful.
_hzfunc("hzHttpEvent::SendNotFound") ;
hzChain Z ; // Output chain
Z <<
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 5.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL "
<< url << " was not found on this server.</p>\n<hr>\n"
;
Z.Printf("<address>HadronZoo Internet: %s Port %d</address>\n", *url.Domain(), url.Port()) ;
Z << "</body></html>\n" ;
if (SendRawChain(HTTPMSG_NOTFOUND, HMTYPE_TXT_HTML, Z, 0,false) != E_OK)
{
hzerr(E_WRITEFAIL, "Response data not sent (size=%d, sock=%d)", Z.Size(), m_pCx->CliSocket()) ;
return E_WRITEFAIL ;
}
return E_OK ;
}