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


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

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


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

示例2: serverURLStr


//.........这里部分代码省略.........
         static const set< MC2String, strNoCaseCompareLess > notForwardHeaders( 
            BEGIN_ARRAY( notForwardHeadersStr ), 
            END_ARRAY( notForwardHeadersStr ) );
         
         if ( inHeaders != NULL ) {
            const HttpHeader::HeaderMap& headers = inHeaders->getHeaderMap();
            for ( HttpHeader::HeaderMap::const_iterator it = headers.begin() ;
                  it != headers.end() ; ++it ) {
               if ( notForwardHeaders.find( it->first ) == 
                    notForwardHeaders.end() ) {
                  sendHeaders.addHeaderLine( it->first, *it->second );
               }
            }
         }
         
         if ( postData.empty() ) {
            ures = f->get(  reply, outHeaders, url2, 
                            timeout, &sendHeaders );
         } else {
            if ( inHeaders->getHeaderValue( "X-WAYF-CT" ) != NULL ) {
               sendHeaders.addHeaderLine( 
                  HttpHeaderLines::CONTENT_TYPE,
                  *inHeaders->getHeaderValue( "X-WAYF-CT" ) );
            } else {
               sendHeaders.addHeaderLine( 
                  HttpHeaderLines::CONTENT_TYPE, 
                  "application/x-www-form-urlencoded" );
            }
            ures = f->post( reply, outHeaders, url2, postData, 
                            timeout, &sendHeaders );
         }
         // Reset user agent
         //f->setDefaultUserAgent();
      }
   } // if (! fetchedThruProxy )
   
   // Remove chunked-encoding from reply (if present)
   const MC2String teh( "Transfer-Encoding" );
   const MC2String* te = outHeaders.getHeaderValue( &teh );
   if ( te != NULL && ( te->find( "chunked") != MC2String::npos ) ) {
      outHeaders.deleteHeaderLine( &teh );
   }
      
   // Check if web updated user
   const MC2String wfidh( "X-WFID-UPDATE" );
   const MC2String* wfid = outHeaders.getHeaderValue( &wfidh );
   if ( wfid != NULL ) {
      // Remove the uin from user cache
      uint32 uin = STLStringUtility::strtoul( *wfid );
      m_group->removeUserFromCache( uin );

      // And remove the header
      outHeaders.deleteHeaderLine( &wfidh );
   }

   // Make reply
   const MC2String eol( "\r\n" );
   if ( fromByte > toByte ) {
      toByte = fromByte;
   }
   const uint32 maxBytes = toByte - fromByte;
   uint32 lastByte = uint32( MAX( int32(reply.size()) - 1, 0 ) );
   startByte = MIN( fromByte, lastByte );
   endByte = startByte + MIN( lastByte - startByte, maxBytes );

   if ( ures > 0 && reply.size() > 0 && 
        (endByte != lastByte || startByte != 0) ) 
   {
      // Set byte range in reply
      MC2String rangeStr( "bytes " );
      STLStringUtility::uint2str( startByte, rangeStr );
      rangeStr.append( "-" );
      STLStringUtility::uint2str( endByte, rangeStr );
      rangeStr.append( "/" );
      STLStringUtility::uint2str( reply.size(), rangeStr ); // Real size
      outHeaders.addHeaderLine( "Content-Range", rangeStr );
      rangeStr = "";
      STLStringUtility::uint2str( endByte - startByte + 1, rangeStr );
      // Set right content length
      outHeaders.addHeaderLine( "Content-Length", rangeStr );
      // Set startline with 206 Partial Content
      MC2String responce( outHeaders.getStartLine()->substr( 0, 9 ) );
      responce.append( "206 Partial Content" );
      responce.append( eol );
      outHeaders.setStartLine( new MC2String( responce ) );
   } else if ( ures < 0 || outHeaders.getStartLine() == NULL ) {
      if ( TimeUtility::getCurrentTime() - startTime >= timeout ) {
         outHeaders.setStartLine( 503 );
      } else {
         outHeaders.setStartLine( 500 );
      }
   } else {
      // Set startline with eol
      outHeaders.setStartLine( 
         new MC2String( StringUtility::trimStartEnd( 
                           *outHeaders.getStartLine() ) + eol ) );
   }

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


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