本文整理汇总了C++中HttpReq::getLocationLen方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getLocationLen方法的具体用法?C++ HttpReq::getLocationLen怎么用?C++ HttpReq::getLocationLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpReq
的用法示例。
在下文中一共展示了HttpReq::getLocationLen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processHeaderLine
//.........这里部分代码省略.........
if ( !HttpGlobals::getMime()->compressable( pValue ) )
pReq->setGzip( 0 );
*p1 = ch;
}
if ( pReq->isKeepAlive() )
pReq->smartKeepAlive( pValue );
{
if ( !HttpMime::needCharset( pValue ) )
break;
const AutoStr2 * pCharset = pReq->getDefaultCharset();
if ( !pCharset )
break;
if ( p )
{
while( isspace( *(++p) ) )
;
if ( strncmp( p, "charset=", 8 ) == 0 )
break;
}
AutoBuf& buf = pResp->getOutputBuf();
if ( buf.available() < pLineEnd - pLineBegin + pCharset->len() + 4 )
{
buf.grow( pLineEnd - pLineBegin + pCharset->len() + 4 );
}
buf.appendNoCheck( pLineBegin, pLineEnd - pLineBegin );
buf.appendNoCheck( pCharset->c_str(), pCharset->len() );
buf.appendNoCheck( "\r\n", 2 );
}
return 0;
case HttpHeader::H_CONTENT_ENCODING:
pReq->setGzip( 0 );
break;
case HttpHeader::H_LOCATION:
if ( pReq->getStatusCode() != SC_200 )
break;
if ( *pValue != '/' )
{
//set status code to 307
pReq->setStatusCode( SC_302 );
}
else
{
pReq->setLocation( pValue, pLineEnd - pValue );
return 0;
}
break;
case HttpHeader::CGI_STATUS:
index = HttpStatusCode::codeToIndex( pValue );
if ( index != -1 )
{
pReq->updateNoRespBodyByStatus( index );
if (( index >= SC_300 )&&( index < SC_400 ))
{
if ( *pReq->getLocation() )
{
pResp->appendHeader( "Location: ", 10,
pReq->getLocation(), pReq->getLocationLen() );
pReq->clearLocation();
}
}
if (( status & HEC_RESP_AUTHORIZER )&&( index == SC_200))
status |= HEC_RESP_AUTHORIZED;
}
return 0;
case HttpHeader::H_TRANSFER_ENCODING:
pResp->setContentLen( -1 );
return 0;
case HttpHeader::H_PROXY_CONNECTION:
case HttpHeader::H_CONNECTION:
if ( strncasecmp( pValue, "close", 5 ) == 0 )
status |= HEC_RESP_CONN_CLOSE;
return 0;
case HttpHeader::H_CONTENT_LENGTH:
if ( pResp->getContentLen() >= 0 )
{
long lContentLen = strtol( pValue, NULL, 10 );
if (( lContentLen >= 0 )&&( lContentLen != LONG_MAX ))
pResp->setContentLen( lContentLen );
}
//fall through
case HttpHeader::H_KEEP_ALIVE:
case HttpHeader::H_SERVER:
case HttpHeader::H_DATE:
return 0;
default:
//"script-control: no-abort" is not supported
break;
}
if ( status & HEC_RESP_AUTHORIZED )
{
if (strncasecmp( pLineBegin, "Variable-", 9 ) == 0 )
{
if ( pKeyEnd > pLineBegin + 9 )
pReq->addEnv( pLineBegin + 9, pKeyEnd - pLineBegin - 9,
pValue, pLineEnd - pValue );
}
return 0;
}
return pResp->appendHeaderLine( pLineBegin, pLineEnd );
}
示例2: processHeaderLine
//.........这里部分代码省略.........
// else //if ( strncasecmp( pValue, "deflate", 7 ) == 0 )
// {
// pReq->andGzip( ~GZIP_ENABLED );
// }
break;
case HttpRespHeaders::H_LOCATION:
if ((status & HEC_RESP_PROXY) || (pReq->getStatusCode() != SC_200))
break;
case HttpRespHeaders::H_LITESPEED_LOCATION:
if (*pValue != '/')
{
//set status code to 307
pReq->setStatusCode(SC_302);
}
else
{
if ((pReq->getStatusCode() == SC_404) ||
(index == HttpRespHeaders::H_LITESPEED_LOCATION))
pReq->setStatusCode(SC_200);
if (index == HttpRespHeaders::H_LITESPEED_LOCATION)
{
char ch = *pLineEnd;
*((char *)pLineEnd) = 0;
pReq->locationToUrl(pValue, pLineEnd - pValue);
*((char *)pLineEnd) = ch;
}
else
pReq->setLocation(pValue, pLineEnd - pValue);
pExtConn->getHttpSession()->changeHandler();
//status |= HEC_RESP_LOC_SET;
return 0;
}
break;
case HttpRespHeaders::H_CGI_STATUS:
tmpIndex = HttpStatusCode::getInstance().codeToIndex(pValue);
if (tmpIndex != -1)
{
pReq->updateNoRespBodyByStatus(tmpIndex);
if ((tmpIndex >= SC_300) && (tmpIndex < SC_400))
{
if (pReq->getLocation() != NULL)
{
pResp->appendHeader("location: ", 10,
pReq->getLocation(), pReq->getLocationLen());
pReq->clearLocation();
}
}
if ((status & HEC_RESP_AUTHORIZER) && (tmpIndex == SC_200))
status |= HEC_RESP_AUTHORIZED;
}
return 0;
case HttpRespHeaders::H_TRANSFER_ENCODING:
pResp->setContentLen(LSI_RSP_BODY_SIZE_CHUNKED);
return 0;
case HttpRespHeaders::H_SET_COOKIE:
//pReq->getRespCacheCtrl().setHasCookie();
pReq->processSetCookieHeader(pValue, pLineEnd - pValue);
break;
case HttpRespHeaders::H_PROXY_CONNECTION:
case HttpRespHeaders::H_CONNECTION:
if (strncasecmp(pValue, "close", 5) == 0)
status |= HEC_RESP_CONN_CLOSE;
return 0;
case HttpRespHeaders::H_CONTENT_LENGTH:
if (pResp->getContentLen() == LSI_RSP_BODY_SIZE_UNKNOWN)
{
off_t lContentLen = strtoll(pValue, NULL, 10);
if ((lContentLen >= 0) && (lContentLen != LLONG_MAX))
{
pResp->setContentLen(lContentLen);
status |= HEC_RESP_CONT_LEN;
pReq->orContextState(RESP_CONT_LEN_SET);
}
}
//fall through
case HttpRespHeaders::H_KEEP_ALIVE:
case HttpRespHeaders::H_SERVER:
case HttpRespHeaders::H_DATE:
return 0;
default:
//"script-control: no-abort" is not supported
break;
}
if (status & HEC_RESP_AUTHORIZED)
{
if (strncasecmp(pLineBegin, "Variable-", 9) == 0)
{
if (pKeyEnd > pLineBegin + 9)
RequestVars::setEnv(pExtConn->getHttpSession(), pLineBegin + 9,
pKeyEnd - pLineBegin - 9,
pValue, pLineEnd - pValue);
}
return 0;
}
assert(pKeyEnd);
return pResp->appendHeader(pLineBegin, pKeyEnd - pLineBegin, pValue,
pLineEnd - pValue);
}