本文整理汇总了C++中HttpReq::getOrgReqURL方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getOrgReqURL方法的具体用法?C++ HttpReq::getOrgReqURL怎么用?C++ HttpReq::getOrgReqURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpReq
的用法示例。
在下文中一共展示了HttpReq::getOrgReqURL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildCommonEnv
int HttpCgiTool::buildCommonEnv( IEnv * pEnv, HttpConnection * pConn )
{
int count = 0;
HttpReq * pReq = pConn->getReq();
const char * pTemp;
int n;
int i;
char buf[128];
pTemp = pReq->getAuthUser();
if ( *pTemp )
{
//FIXME: only Basic is support now
pEnv->add( "AUTH_TYPE", 9, "Basic", 5 );
pEnv->add( "REMOTE_USER", 11, pTemp, strlen( pTemp ) );
count += 2;
}
//ADD_ENV("REMOTE_IDENT", "" ) //FIXME: not supported yet
//extensions of CGI/1.1
const AutoStr2 * pDocRoot = pReq->getDocRoot();
pEnv->add( "DOCUMENT_ROOT", 13,
pDocRoot->c_str(), pDocRoot->len()-1 );
pEnv->add( "REMOTE_ADDR", 11, pConn->getPeerAddrString(),
pConn->getPeerAddrStrLen() );
n = safe_snprintf( buf, 10, "%hu", pConn->getRemotePort() );
pEnv->add( "REMOTE_PORT", 11, buf, n );
n = pConn->getServerAddrStr( buf, 128 );
pEnv->add( "SERVER_ADDR", 11, buf, n );
pEnv->add( "SERVER_NAME", 11, pReq->getHostStr(), pReq->getHostStrLen() );
const AutoStr2 &sPort = pReq->getPortStr();
pEnv->add( "SERVER_PORT", 11, sPort.c_str(), sPort.len() );
pEnv->add( "REQUEST_URI", 11, pReq->getOrgReqURL(), pReq->getOrgReqURLLen() );
count += 7;
n = pReq->getPathInfoLen();
if ( n > 0)
{
int m;
char achTranslated[10240];
m = pReq->translatePath( pReq->getPathInfo(), n,
achTranslated, sizeof( achTranslated ) );
if ( m != -1 );
{
pEnv->add( "PATH_TRANSLATED", 15, achTranslated, m );
++count;
}
pEnv->add( "PATH_INFO", 9, pReq->getPathInfo(), n);
++count;
}
//add geo IP env here
if ( pReq->isGeoIpOn() )
{
GeoInfo * pInfo = pConn->getClientInfo()->getGeoInfo();
if ( pInfo )
{
pEnv->add( "GEOIP_ADDR", 10, pConn->getPeerAddrString(),
pConn->getPeerAddrStrLen() );
count += pInfo->addGeoEnv( pEnv )+1;
}
}
n = pReq->getEnvCount();
count += n;
for( i = 0; i < n; ++i )
{
const char * pKey;
const char * pVal;
int keyLen;
int valLen;
pKey = pReq->getEnvByIndex( i, keyLen, pVal, valLen );
if ( pKey )
pEnv->add( pKey, keyLen, pVal, valLen );
}
if ( pConn->isSSL() )
{
SSLConnection * pSSL = pConn->getSSL();
pEnv->add( "HTTPS", 5, "on", 2 );
const char * pVersion = pSSL->getVersion();
n = strlen( pVersion );
pEnv->add( "SSL_VERSION", 11, pVersion, n );
count += 2;
SSL_SESSION * pSession = pSSL->getSession();
if ( pSession )
{
int idLen = SSLConnection::getSessionIdLen( pSession );
n = idLen * 2;
assert( n < (int)sizeof( buf ) );
StringTool::hexEncode(
(char *)SSLConnection::getSessionId( pSession ),
idLen, buf );
pEnv->add( "SSL_SESSION_ID", 14, buf, n );
++count;
}
//.........这里部分代码省略.........
示例2: getReqVar
//.........这里部分代码省略.........
}
return 0;
}
case REF_PATH_INFO:
pValue = (char *)pReq->getPathInfo();
return pReq->getPathInfoLen();
case REF_SCRIPT_NAME:
pValue = (char *)pReq->getURI();
return pReq->getScriptNameLen();
case REF_SCRIPT_URI:
p = pValue;
if ( pSession->isSSL() )
{
strcpy( p, "https://" );
p += 8;
}
else
{
strcpy( p, "http://" );
p += 7;
}
i = pReq->getHeaderLen( HttpHeader::H_HOST );
memmove( p, pReq->getHeader( HttpHeader::H_HOST ),
i );
p += i;
i = pReq->getOrgURILen();
memmove( p, pReq->getOrgURI(), i );
p += i;
return p - pValue;
case REF_ORG_REQ_URI:
pValue = (char *)pReq->getOrgReqURL();
return pReq->getOrgReqURILen();
case REF_DOCUMENT_URI:
return pReq->getDecodedOrgReqURI( pValue );
case REF_REQ_URI:
pValue = (char *)pReq->getOrgReqURL();
return pReq->getOrgReqURLLen();
case REF_DOC_ROOT:
pValue = (char *)pReq->getDocRoot()->c_str();
return pReq->getDocRoot()->len()-1;
case REF_SERVER_ADMIN:
if ( pReq->getVHost() )
{
const AutoStr2 * pEmail = pReq->getVHost()->getAdminEmails();
pValue = (char *)pEmail->c_str();
return pEmail->len();
}
return 0;
case REF_VH_CNAME:
if ( pReq->getVHost() )
{
pValue = (char *)pReq->getVHost()->getVhName( i );
return i;
}
return 0;
case REF_SERVER_NAME:
pValue = (char *)pReq->getHostStr();
return pReq->getHostStrLen();
case REF_SERVER_ADDR:
pValue = (char *)pReq->getLocalAddrStr()->c_str();
示例3: getSubstValue
//.........这里部分代码省略.........
{
case REF_STRING:
pValue = (char *)pItem->getStr()->c_str();
return pItem->getStr()->len();
case REF_MAP:
{
MapRefItem * pRef = pItem->getMapRef();
int len = 1024;
char achBuf[1024];
if ( buildString( pRef->getKeyFormat(), pConn, achBuf, len ) == NULL )
return 0;
if ( (len = pRef->getMap()->lookup( achBuf, len, pValue, bufLen )) == -1 )
{
if ( pRef->getDefaultFormat() )
{
if ( buildString( pRef->getDefaultFormat(), pConn,
pValue, bufLen ) == NULL )
return 0;
len = bufLen;
}
else
len = 0;
}
return len;
}
break;
case REF_RULE_SUBSTR:
return getSubstr( m_pSourceURL, m_ruleVec, m_ruleMatches, pItem->getIndex(),
pValue, m_flag & RULE_FLAG_BR_ESCAPE );
case REF_COND_SUBSTR:
return getSubstr( m_pCondBuf, m_condVec, m_condMatches, pItem->getIndex(),
pValue, m_flag & RULE_FLAG_BR_ESCAPE );
case REF_ENV:
pValue = (char *)RequestVars::getEnv( pConn, pItem->getStr()->c_str(),
pItem->getStr()->len(), i );
if ( !pValue )
{
i = 0;
}
return i;
case REF_HTTP_HEADER:
pValue = (char *)pReq->getHeader( pItem->getStr()->c_str(),
pItem->getStr()->len(), i );
if ( !pValue )
i = 0;
return i;
case REF_REQUST_FN:
case REF_SCRIPTFILENAME:
if ( m_iScriptLen == -1 )
{
pReq->checkPathInfo( m_pSourceURL, m_sourceURLLen, m_iFilePathLen,
m_iScriptLen, m_iPathInfoLen, m_pContext );
}
pValue = HttpGlobals::g_achBuf;
//if ( m_pStrip )
// return m_iFilePathLen;
//else
// return m_iFilePathLen + m_iPathInfoLen;
return m_iFilePathLen;
case REF_PATH_INFO:
if ( m_iScriptLen == -1 )
{
pReq->checkPathInfo( m_pSourceURL, m_sourceURLLen, m_iFilePathLen,
m_iScriptLen, m_iPathInfoLen, m_pContext );
}
pValue = &HttpGlobals::g_achBuf[ m_iFilePathLen ];
return m_iPathInfoLen;
case REF_SCRIPT_NAME:
if ( m_iScriptLen == -1 )
{
pReq->checkPathInfo( m_pSourceURL, m_sourceURLLen, m_iFilePathLen,
m_iScriptLen, m_iPathInfoLen, m_pContext );
}
pValue = (char *)pReq->getOrgReqURL();
return m_iScriptLen;
case REF_REQ_URI: //in rewrite rule, this does not include Query String part
if ( pReq->getRedirects() == 0 )
{
pValue = (char *)pReq->getOrgReqURL();
return pReq->getOrgReqURILen();
}
if ( m_pStrip )
{
memmove( pValue, m_pStrip->c_str(), m_pStrip->len() );
memmove( pValue + m_pStrip->len(), m_pSourceURL, m_sourceURLLen );
return m_pStrip->len() + m_sourceURLLen;
}
//fall through
case REF_CUR_URI:
pValue = (char *)m_pSourceURL;
return m_sourceURLLen;
case REF_QUERY_STRING:
pValue = (char *)m_pQS;
return m_qsLen;
default:
return RequestVars::getReqVar( pConn, type, pValue, bufLen );
}
return 0;
}
示例4: buildCommonEnv
int HttpCgiTool::buildCommonEnv(IEnv *pEnv, HttpSession *pSession)
{
int count = 0;
HttpReq *pReq = pSession->getReq();
const char *pTemp;
int n;
char buf[128];
RadixNode *pNode;
pTemp = pReq->getAuthUser();
if (pTemp)
{
//NOTE: only Basic is support now
pEnv->add("AUTH_TYPE", 9, "Basic", 5);
pEnv->add("REMOTE_USER", 11, pTemp, strlen(pTemp));
count += 2;
}
//ADD_ENV("REMOTE_IDENT", "" ) //TODO: not supported yet
//extensions of CGI/1.1
const AutoStr2 *pDocRoot = pReq->getDocRoot();
pEnv->add("DOCUMENT_ROOT", 13,
pDocRoot->c_str(), pDocRoot->len() - 1);
pEnv->add("REMOTE_ADDR", 11, pSession->getPeerAddrString(),
pSession->getPeerAddrStrLen());
n = ls_snprintf(buf, 10, "%hu", pSession->getRemotePort());
pEnv->add("REMOTE_PORT", 11, buf, n);
n = pSession->getServerAddrStr(buf, 128);
pEnv->add("SERVER_ADDR", 11, buf, n);
pEnv->add("SERVER_NAME", 11, pReq->getHostStr(), pReq->getHostStrLen());
const AutoStr2 &sPort = pReq->getPortStr();
pEnv->add("SERVER_PORT", 11, sPort.c_str(), sPort.len());
pEnv->add("REQUEST_URI", 11, pReq->getOrgReqURL(),
pReq->getOrgReqURLLen());
count += 7;
n = pReq->getPathInfoLen();
if (n > 0)
{
int m;
char achTranslated[10240];
m = pReq->translatePath(pReq->getPathInfo(), n,
achTranslated, sizeof(achTranslated));
if (m != -1)
{
pEnv->add("PATH_TRANSLATED", 15, achTranslated, m);
++count;
}
pEnv->add("PATH_INFO", 9, pReq->getPathInfo(), n);
++count;
}
//add geo IP env here
if (pReq->isGeoIpOn())
{
GeoInfo *pInfo = pSession->getClientInfo()->getGeoInfo();
if (pInfo)
{
pEnv->add("GEOIP_ADDR", 10, pSession->getPeerAddrString(),
pSession->getPeerAddrStrLen());
count += pInfo->addGeoEnv(pEnv) + 1;
}
}
n = pReq->getEnvCount();
count += n;
if ((pNode = (RadixNode *)pReq->getEnvNode()) != NULL)
pNode->for_each2(addEnv, pEnv);
if (pSession->getStream()->isSpdy())
{
const char *pProto = HioStream::getProtocolName((HiosProtocol)
pSession->getStream()->getProtocol());
pEnv->add("X_SPDY", 6, pProto, strlen(pProto));
++count;
}
if (pSession->isSSL())
{
SslConnection *pSSL = pSession->getSSL();
pEnv->add("HTTPS", 5, "on", 2);
const char *pVersion = pSSL->getVersion();
n = strlen(pVersion);
pEnv->add("SSL_VERSION", 11, pVersion, n);
count += 2;
SSL_SESSION *pSession = pSSL->getSession();
if (pSession)
{
int idLen = SslConnection::getSessionIdLen(pSession);
n = idLen * 2;
assert(n < (int)sizeof(buf));
StringTool::hexEncode(
(char *)SslConnection::getSessionId(pSession),
idLen, buf);
pEnv->add("SSL_SESSION_ID", 14, buf, n);
++count;
}
//.........这里部分代码省略.........