本文整理汇总了C++中HttpHeader::getStartLine方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpHeader::getStartLine方法的具体用法?C++ HttpHeader::getStartLine怎么用?C++ HttpHeader::getStartLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHeader
的用法示例。
在下文中一共展示了HttpHeader::getStartLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}