本文整理汇总了C++中TimeStamp::currentTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStamp::currentTime方法的具体用法?C++ TimeStamp::currentTime怎么用?C++ TimeStamp::currentTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeStamp
的用法示例。
在下文中一共展示了TimeStamp::currentTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serve
void FileHandler::serve( Falcon::WOPI::Request* req )
{
String sMimeType;
// Get the document -- for now a very simple thing
if ( ! m_client->options().findMimeType( m_sFile, sMimeType ) )
sMimeType = "unknown";
// Send the file
Falcon::FileStat stats;
if( ! Falcon::Sys::fal_stats( m_sFile, stats ) )
{
m_client->replyError( 403 );
return;
}
FileStream fs;
if( ! fs.open( m_sFile ) )
{
m_client->log()->log( LOGLEVEL_WARN, "Can't open file "+ m_sFile );
m_client->replyError( 403 );
return;
}
m_client->log()->log( LOGLEVEL_INFO, "Sending file "+ m_sFile );
// ok we can serve the file
String sReply = "HTTP/1.1 200 OK\r\n";
TimeStamp now;
now.currentTime();
sReply += "Content-Type: " + sMimeType + "; charset=" + m_client->options().m_sTextEncoding + "\r\n";
sReply += "Date: " + now.toRFC2822() + "\r\n";
sReply += "Last-Modified: " + stats.m_mtime->toRFC2822() + "\r\n";
sReply += "\r\n";
// content length not strictly necessary now
m_client->sendData( sReply );
char buffer[4096];
int len = fs.read( buffer, 4096 );
while( len > 0 )
{
m_client->sendData( buffer, len );
len = fs.read( buffer, 4096 );
}
if ( len < 0 )
{
// error!
m_client->log()->log( LOGLEVEL_WARN, "Error while reading file "+ m_sFile );
m_client->replyError( 403 );
}
}
示例2: replyError
void FalhttpdClient::replyError( int errorID, const String& explain )
{
String sErrorDesc = codeDesc( errorID );
String sReply;
String sError;
sReply.A("HTTP/1.1 ").N( errorID ).A( " " + sErrorDesc + "\r\n");
sError.N(errorID ).A( ": " + sErrorDesc );
// for now, we create the docuemnt here.
// TODO Read the error document from a file.
String sErrorDoc = "<html>\n"
"<head>\r\n"
"<title>Error " +sError + "</title>\n"
"</head>\n"
"<body>\n"
"<h1>" + sError + "</h1>\n";
if( explain.size() != 0 )
{
sErrorDoc += "<p>This abnormal condition has been encountered while receiving and processing Your request:</p>\n";
sErrorDoc += "<p><b>" + explain + "</b></p>\n";
}
else
{
sErrorDoc += "<p>An error of type <b>" + sError + "</b> has been detected while parsing your request.</p>\n";
}
sErrorDoc += getServerSignature();
sErrorDoc += "</body>\n</html>\n";
AutoCString content( sErrorDoc );
TimeStamp now;
now.currentTime();
sReply += "Date: " + now.toRFC2822() + "\r\n";
sReply.A( "Content-Length: ").N( (int64) content.length() ).A("\r\n");
sReply += "Content-Type: text/html; charset=utf-8\r\n\r\n";
m_log->log( LOGLEVEL_INFO, "Sending ERROR reply to client " + m_sRemote + ": " + sError );
sendData( sReply );
sendData( content.c_str(), content.length() );
}