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