本文整理汇总了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__);
}