本文整理汇总了C++中HeaderMap类的典型用法代码示例。如果您正苦于以下问题:C++ HeaderMap类的具体用法?C++ HeaderMap怎么用?C++ HeaderMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HeaderMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleRequest
// implementing RequestHandler
virtual void handleRequest(Transport *transport) {
g_context.getCheck();
HeaderMap headers;
transport->getHeaders(headers);
std::string response;
response = "\nGET param: name = ";
response += transport->getParam("name");
if (transport->getMethod() == Transport::Method::POST) {
int size = 0;
auto const data = (const char *)transport->getPostData(size);
response += "\nPOST data: ";
response += std::string(data, size);
}
for (HeaderMap::const_iterator iter = headers.begin();
iter != headers.end(); ++iter) {
response += "\nHeader: ";
response += iter->first;
for (unsigned int i = 0; i < iter->second.size(); i++) {
response += "\n";
response += folly::to<std::string>(i);
response += ": ";
response += iter->second[i];
}
}
transport->addHeader("Custom", "blah");
transport->sendString(response);
hphp_memory_cleanup();
}
示例2: handleRequest
// implementing RequestHandler
virtual void handleRequest(Transport *transport) {
HeaderMap headers;
transport->getHeaders(headers);
string response;
response = "\nGET param: name = ";
response += transport->getParam("name");
if (transport->getMethod() == Transport::POST) {
int size = 0;
const char *data = (const char *)transport->getPostData(size);
response += "\nPOST data: ";
response += string(data, size);
}
for (HeaderMap::const_iterator iter = headers.begin();
iter != headers.end(); ++iter) {
response += "\nHeader: ";
response += iter->first;
for (unsigned int i = 0; i < iter->second.size(); i++) {
response += "\n";
response += lexical_cast<string>(i);
response += ": ";
response += iter->second[i];
}
}
transport->addHeader("Custom", "blah");
transport->sendString(response);
}
示例3: headerMapToString
string HeaderInterface::headerMapToString( const HeaderMap& h )
{
string headerMap = "";
for ( HeaderMap::const_iterator iter = h.begin(); iter != h.end(); ++iter ) {
headerMap += keyValuePairToString( *iter, ":" ) + sCrLf;
}
return headerMap;
}
示例4: GetValue
GetValue(const char16_t* pKey)
#endif
const
{
HeaderMap* headerMapPtr = reinterpret_cast<HeaderMap*>(mHeaderMap);
EA::WebKit::HeaderMap::iterator itWK = headerMapPtr->find_as(pKey, EA::WebKit::str_iless());
if(itWK != headerMapPtr->end())
return itWK->second.c_str();
return 0;
}
示例5: Group
void SavingCtrlObj::HwSavingStream::setCommonHeader(const HeaderMap& headerMap) {
DEB_MEMBER_FUNCT();
if (!headerMap.empty()) {
Group header = Group(m_entry->createGroup("Header"));
for (map<string, string>::const_iterator it = headerMap.begin(); it != headerMap.end(); it++) {
string key = it->first;
string value = it->second;
write_h5_dataset(header, key.c_str(), value);
}
}
}
示例6: stringToHeaderMap
HeaderMap HeaderInterface::stringToHeaderMap( const string& h )
{
vector<string> tokens;
boost::split( tokens, h, boost::is_any_of( sCrLf ) );
HeaderMap headerMap;
for ( vector<string>::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter ) {
if ( !iter->empty() ) {
KeyValuePair kvp = stringToKeyValuePair( *iter, ":" );
headerMap.insert( kvp );
}
}
return headerMap;
}
示例7: f_apache_response_headers
Array f_apache_response_headers() {
Transport *transport = g_context->getTransport();
if (transport) {
HeaderMap headers;
transport->getResponseHeaders(headers);
Array ret;
for (auto iter = headers.begin(); iter != headers.end(); ++iter) {
const auto& values = iter->second;
ret.set(String(iter->first), String(values.back()));
}
return ret;
}
return Array();
}
示例8: EAWEBKIT_NEW
EASTLHeaderMapWrapper::EASTLHeaderMapWrapperIterator* EASTLHeaderMapWrapper::First()
{
HeaderMap* headerMapPtr = reinterpret_cast<HeaderMap*>(mHeaderMap);
if(headerMapPtr && !headerMapPtr->empty())
{
if(!mHeaderMapWrapperIterator)
mHeaderMapWrapperIterator = EAWEBKIT_NEW("HeaderMapIteratorWrapper") EASTLHeaderMapWrapperIterator();
*(reinterpret_cast<HeaderMap::iterator*>(mHeaderMapWrapperIterator->mIterator)) = headerMapPtr->begin();
return mHeaderMapWrapperIterator;
}
return 0;
}
示例9: f_apache_request_headers
Array f_apache_request_headers() {
Transport *transport = g_context->getTransport();
if (transport) {
HeaderMap headers;
transport->getHeaders(headers);
Array ret;
for (HeaderMap::const_iterator iter = headers.begin();
iter != headers.end(); ++iter) {
const vector<string> &values = iter->second;
ret.set(String(iter->first), String(values.back()));
}
return ret;
}
return Array();
}
示例10: SetValue
SetValue(const char16_t* pKey, const char16_t* pValue)
#endif
{
HeaderMap* headerMapPtr = reinterpret_cast<HeaderMap*>(mHeaderMap);
EA::WebKit::HeaderMap::iterator itWK = headerMapPtr->find_as(pKey, EA::WebKit::str_iless());
if(itWK != headerMapPtr->end())
{
itWK->second = pValue;
}
else
{
const EA::WebKit::HeaderMap::value_type entry(pKey, pValue);
headerMapPtr->insert(entry);
}
}
示例11: EAW_ASSERT_MSG
EASTLHeaderMapWrapper::EASTLHeaderMapWrapperIterator* EASTLHeaderMapWrapper::GetNext()
{
EAW_ASSERT_MSG(mHeaderMapWrapperIterator, "Please make sure to call EASTLHeaderMapWrapper::First() before this. See header file for documentation.\n");
if(mHeaderMapWrapperIterator)
{
HeaderMap* headerMapPtr = reinterpret_cast<HeaderMap*>(mHeaderMap);
HeaderMap::iterator& headerMapIterator = *(reinterpret_cast<HeaderMap::iterator*>(mHeaderMapWrapperIterator->mIterator));
++headerMapIterator;
if(headerMapIterator != headerMapPtr->end())
return mHeaderMapWrapperIterator;
}
return 0;
}
示例12: HHVM_FUNCTION
Array HHVM_FUNCTION(headers_list) {
Transport *transport = g_context->getTransport();
Array ret = Array::Create();
if (transport) {
HeaderMap headers;
transport->getResponseHeaders(headers);
for (HeaderMap::const_iterator iter = headers.begin();
iter != headers.end(); ++iter) {
const std::vector<std::string> &values = iter->second;
for (unsigned int i = 0; i < values.size(); i++) {
ret.append(String(iter->first + ": " + values[i]));
}
}
}
return ret;
}
示例13: OnConnected
bool HTTPSocket::OnConnected()
{
std::string request = "GET " + url.request + " HTTP/1.1\r\n";
// Dump headers into the request
HeaderMap headers = req.GetHeaders();
for (HeaderMap::iterator i = headers.begin(); i != headers.end(); i++)
request += i->first + ": " + i->second + "\r\n";
// The Host header is required for HTTP 1.1 and isn't known when the request is created; if they didn't overload it
// manually, add it here
if (headers.find("Host") == headers.end())
request += "Host: " + url.domain + "\r\n";
request += "\r\n";
this->status = HTTP_REQSENT;
return this->Write(request);
}
示例14: get_headers
static Array get_headers(const HeaderMap& headers, bool allHeaders = false) {
ArrayInit ret(headers.size(), ArrayInit::Mixed{});
for (auto& iter : headers) {
const auto& values = iter.second;
if (auto size = values.size()) {
if (!allHeaders) {
ret.set(String(iter.first), String(values.back()));
} else {
PackedArrayInit dups(size);
for (auto& dup : values) {
dups.append(String(dup));
}
ret.set(String(toLower(iter.first)), dups.toArray());
}
}
}
return ret.toArray();
}
示例15: ossReq
Response ConnectionImpl::Request( const std::string & method, const std::string & url, const HeaderMap & header )
{
HeaderMap hm;
hm["Host"] = this->HostName;
hm["Connection"] = "close";
hm.Update( header );
std::ostringstream ossReq( std::ios::binary ); // \r\n を正しく処理するためバイナリとする。
ossReq << method << " " << url << " HTTP/1.1\r\n" << hm.ToString() << "\r\n" << '\0';
this->makeConnection();
this->sendRequest( ossReq.str() );
std::ostringstream ossResult( std::ios::binary );
const int BufferSize = 256;
char buf[BufferSize+1];
// サーバからヘッダ部を受信
while( 1 )
{
int readSize = this->receive( buf, BufferSize );
if( readSize > 0 )
{
buf[readSize] = '\0';
std::string bufStr( buf );
std::string::size_type endOfHeader = bufStr.find( "\r\n\r\n" );
if( endOfHeader == std::string::npos )
{
ossResult.write( buf, readSize );
}
else
{
ossResult.write( buf, readSize );
break;
}
}
else if( readSize == 0 )
{
break;
}
else
{
throw CACOON_EXCEPTION( "recv エラー" );
}
}
std::string respHeaderStr = ossResult.str();
std::string::size_type firstLine = respHeaderStr.find( "\r\n" );
std::string::size_type lastLine = respHeaderStr.find( "\r\n\r\n" );
HeaderMap respHeader( respHeaderStr.substr( firstLine + 2, lastLine - firstLine - 2 ) );
if( respHeader["Transfer-Encoding"] == "chunked" )
{ // サーバから続きを受信 (chunked バージョン)
int chunkSize = 0;
while( 1 )
{
int readSize = this->receive( buf, BufferSize );
if( chunkSize == 0 )
{
if( readSize == 0 )
{
break;
}
buf[readSize-2] = '\0';
chunkSize = strtol( buf, NULL, 16 );
}
else
{
if( readSize > 0 )
{
ossResult.write( buf, readSize );
chunkSize -= readSize;
}
else if( readSize == 0 )
{
break;
}
else
{
throw CACOON_EXCEPTION( "recv エラー" );
}
}
}
}
else
{ // サーバから続きを受信 (普通)
while( 1 )
{
int readSize = this->receive( buf, BufferSize );
if( readSize > 0 )
{
ossResult.write( buf, readSize );
break;
}
else if( readSize == 0 )
{
break;
}
else
{
//.........这里部分代码省略.........