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


C++ HttpHeader::getHeaderMap方法代码示例

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


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

示例1:

bool
HttpProxyFunctions::fetchThruProxy( const URL& url,
                                    HttpHeader* outHead,                                   
                                    HttpBody* outBody,
                                    ParserThread* myThread,
                                    HttpVariableContainer* myVar) {
   URLFetcherNoSSL fetcher;
   // return value, true if fetch is successfull
   bool ok = false;

   const char* squid_prop = Properties::getProperty("INTERNAL_SQUID_URL");
   // no need to do proxy if we know about https
   if ( ! myVar->https && squid_prop != NULL ) {
      fetcher.setProxyAddress( squid_prop );
      const uint32 proxyTimeout = Properties::getUint32Property(
         "PROXY_TIMEOUT", 60000 );

      mc2dbg << "[HttpProxyFunc]: Going to fetch: "
             << fetcher.getProxyAddress() + url.getSpec() 
             << endl;

      HttpHeader fetHead;
      HttpHeader extraHeaders;
      extraHeaders.addHeaderLine( 
         X_WF_ID, myThread->getGroup()->getServerInstanceStr() );
      URLFetcherNoSSL::dbPair_t ret = fetcher.get( 
         fetHead, url, proxyTimeout, &extraHeaders );
      if ( (ret.first == HttpCode::OK ||
            ret.first == HttpCode::NOT_FOUND ||
            ret.first == HttpCode::SERVICE_UNAVAILABLE) &&
           ret.second != NULL ) {
         outBody->setBody( ret.second->getBufferAddress(), 
                           ret.second->getBufferSize() );
         const MC2String* hitOrMissTmp = fetHead.getHeaderValue( &X_CACHE );
         MC2String hitOrMiss = hitOrMissTmp ? *hitOrMissTmp : "";
         mc2dbg << "[HttpProxyFunc]: proxy fetch successful "
                << hitOrMiss << endl;
         ok = true;
         // Copy fetHead headers into outHead
         // ARRGH! squid supports only HTTP 1.0 not 1.1 as we do.
         outHead->setStartLine( ret.first ); 
         // Remove confusing proxy headers.
         fetHead.deleteHeaderLine( &PROXY_CONNECTION );
         fetHead.deleteHeaderLine( &CONNECTION );
         fetHead.deleteHeaderLine( &KEEP_ALIVE );
         fetHead.deleteHeaderLine( &X_CACHE );
         fetHead.deleteHeaderLine( &AGE );
         fetHead.deleteHeaderLine( &TRANSFER_ENCODING ); // chunked
         const HttpHeader::HeaderMap& h = fetHead.getHeaderMap();
         for ( HttpHeader::HeaderMap::const_iterator it = h.begin() ;
               it != h.end(); ++it )
         {
            outHead->addHeaderLine( it->first, *it->second );
         }
      } else {
         mc2dbg << "[HttpProxyFunc]: proxy fetch unsuccessfull: "
                << ret.first<< endl;
      }
      // might still be allocated
      delete ret.second;
   }


   return ok;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:65,代码来源:HttpProxyFunctions.cpp


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