当前位置: 首页>>代码示例>>C++>>正文


C++ TimeStamp::currentTime方法代码示例

本文整理汇总了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 );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:54,代码来源:falhttpd_filehandler.cpp

示例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() );

}
开发者ID:Klaim,项目名称:falcon,代码行数:44,代码来源:falhttpd_client.cpp


注:本文中的TimeStamp::currentTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。