Send only the HTTP header for a page to the browser. Returns: None
| Return Type | Function name | Arguments |
|---|---|---|
| void | hdsPage::Head | (hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp
Function Logic:
Function body:
void hdsPage::Head (hzHttpEvent* pE)
{
// Send only the HTTP header for a page to the browser.
//
// Arguments: 1) pE The HTTP event
//
// Returns: None
_hzfunc("hdsPage::Head") ;
ifstream is ; // Read file stream
hzXDate d ; // Date for header lines
hzChain Z ; // Response for browser is built here
const char* pEnd ; // Filename extension and hence type
hzMimetype type ; // File's HTTP type
HttpRC hrc ; // HTTP return code
hzEcode rc ; // Return code from sending function
// Establish real filename, either cpFilename or index.htm(l)
// Determine the type of file so that the correct header can be
// sent to the browser
pEnd = strrchr(*m_Url, CHAR_PERIOD) ;
if (pEnd)
type = Filename2Mimetype(pEnd) ;
else
type = HMTYPE_TXT_HTML ;
// Send the header
Z.Clear() ;
switch (hrc)
{
case HTTPMSG_OK: Z << "HTTP/1.1 200 OK\r\n" ; break ;
case HTTPMSG_NOTFOUND: Z << "HTTP/1.1 404 Not found\r\n" ; break ;
default:
Z.Printf("HTTP/1.1 %03d\r\n", hrc) ;
} ;
d.SysDateTime() ;
Z.Printf("Date: %s\r\n", d.Txt(FMT_DT_INET)) ;
Z << "Server: HTTP/1.0 (HadronZoo, Linux)\r\n" ;
Z.Printf("Last-Modified: %s\r\n", d.Txt(FMT_DT_INET)) ;
d.altdate(SECOND, 1000);
Z.Printf("Expires: %s\r\n", d.Txt(FMT_DT_INET)) ;
Z << "Accept-Ranges: bytes\r\n" ;
if (hrc == HTTPMSG_OK)
Z.Printf("Content-Length: 0\r\n") ;
Z << "Content-Type: " << Mimetype2Txt(type) << "\n\n" ;
pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0,false) ;
}