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


C++ Http::SetWebStreamPtr方法代码示例

本文整理汇总了C++中Http::SetWebStreamPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Http::SetWebStreamPtr方法的具体用法?C++ Http::SetWebStreamPtr怎么用?C++ Http::SetWebStreamPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Http的用法示例。


在下文中一共展示了Http::SetWebStreamPtr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HttpParseHeader

/* Loop the readStream list, and return the already stream */
int StreamManager::HttpParseHeader(){

    WebStream *webStream = NULL;
    list<WebStream *>::iterator ite;
    
    ESLog::ISLog("HTTP HEADER SETS PARSE START\n", __FILE__, __LINE__);

    ESLog::ISLog("readStreamSize:%d\n", __FILE__, __LINE__, this->readStream.size());
    /* loop */
    for( ite = this->readStream.begin(); ite != this->readStream.end(); ++ite ) {

        int result = -1;
        webStream = *ite;

        
        ESLog::ISLog("read webStream->http ptr:%u\n", __FILE__, __LINE__, webStream->GetHttpPtr());
        ESLog::ISLog("read webStream->fd:%d\n", __FILE__, __LINE__, webStream->GetTcpConnFd());
        ESLog::ISLog("read webStream->Status:%s\n", __FILE__, __LINE__, webStream->GetStatusDesc());

        /* if the readStream has writed */
        if( webStream->GetStatus() == WSTREAM_WRITE ) {
            continue;
        }

        /* is http protocol parser exist */
        if( !webStream->IsHttpParserExist() ) {
            ESLog::ISLog("An new Http Object Create \n", __FILE__, __LINE__ );
            Http *httpParser = new Http();
            httpParser->SetWebStreamPtr(webStream);
            webStream->SetHttpParser(httpParser);
            ESLog::ISLog("New Http read webStream->http ptr:%u\n", __FILE__, __LINE__, webStream->GetHttpPtr());
        }

        ESLog::ISLog("read WebStream->HttpStatus:%s\n", __FILE__, __LINE__, webStream->GetHttpPtr()->GetStatusDesc());

        /* if the header has parserd*/
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_REQHEAD_PARSED  ) {
            continue;
        }

        /* if the latest http parsed over, again init http object */
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_RESSEND_OVER  ) {
            
            webStream->GetHttpPtr()->ReInit();
        }

        /* parse the http header, if the http header parsed, then we give the webStream to the
           session/application, it will send to a idle thread to tackle the session
           if return 0, the header parser over; if return > 0 , it still to parser;
           if return < 0 , there is an error happend */
        result = webStream->ParseHttpHeader();  // <--i) set the status of the webStream , http Status
        if( result < 0 ) {
            
            ESLog::ISLog("ParseHttpHeader Erorr START\n", __FILE__, __LINE__ );
            webStream->SetStatus(WSTREAM_ERROR);
            //webStream->GetHttpPtr()->SetStatus(HTTP_RESSEND_OVER);
            //Server::Instance()->GetIOLoop().ModToReadEventFd(webStream->GetTcpConnFd(), (void *)webStream);
            //webStream->ReInit();
            //this->DeleteReadWebStream(webStream);

            Server::Instance()->GetIOLoop().DelReadEventFd(webStream->GetTcpConnFd());

            //webStream->FreeTcpConn();
            //webStream->FreeHttp();
            //webStream->ReInit();
            //webStream->SetStatus(WSTREAM_UNINITILIZED);
            //this->AddIdleStream(webStream);

            ESLog::ISLog("ParseHttpHeader Erorr END\n", __FILE__, __LINE__ );
            continue;
            //break;
            //return  result;  // an error happend
        }

        /* the header has passed  */
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_REQHEAD_PARSED ) {
            //webStream->GetHttpPtr()->SetStatus(2);
            ESLog::ISLog("there is http head parsed\n", __FILE__, __LINE__);
            webStream->SetStatus(WSTREAM_UNDISPATHED);
            this->AddTaskWebStream(webStream);
        }
        
    }

    ESLog::ISLog("HTTP HEADER SETS PARSE END\n", __FILE__, __LINE__);
}
开发者ID:kzhiquan,项目名称:blog-eyesee,代码行数:87,代码来源:StreamManager.cpp


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