当前位置: 首页>>代码示例>>C++>>正文


C++ HttpReq::getQueryStringLen方法代码示例

本文整理汇总了C++中HttpReq::getQueryStringLen方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getQueryStringLen方法的具体用法?C++ HttpReq::getQueryStringLen怎么用?C++ HttpReq::getQueryStringLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpReq的用法示例。


在下文中一共展示了HttpReq::getQueryStringLen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getReqVar

int RequestVars::getReqVar( HttpSession *pSession, int type, char * &pValue, int bufLen)
{
    HttpReq * pReq = pSession->getReq();
    int i;
    char *p;
    if ( type < REF_STRING )
    {
        pValue = (char *)pReq->getHeader( type );
        if ( *pValue )
            return pReq->getHeaderLen( type );
        else
            return 0;
    }
    switch( type )
    {
    case REF_REMOTE_HOST:
        //FIXME: use remote addr for now
    case REF_REMOTE_ADDR:
        pValue = (char *)pSession->getPeerAddrString();
        return pSession->getPeerAddrStrLen();
    case REF_REMOTE_PORT:
        return snprintf( pValue, bufLen, "%hu", pSession->getRemotePort() );
    case REF_REMOTE_USER:
        pValue = (char *)pReq->getAuthUser();
        return strlen( pValue );
    case REF_REMOTE_IDENT:
        //do not support;
        return 0;
    case REF_REQ_METHOD:
        i = pReq->getMethod();
        strcpy(pValue, HttpMethod::get( i ) );
        return HttpMethod::getLen( i );
    case REF_QUERY_STRING:
        pValue = (char *)pReq->getQueryString();
        return pReq->getQueryStringLen();
    case REF_AUTH_TYPE:
        //FIXME: hard code for now
        strncpy( pValue, "Basic", 6 );
        return 5;
    case REF_REQUST_FN:
    case REF_SCRIPTFILENAME:
    case REF_SCRIPT_BASENAME:
    case REF_REQ_BASENAME: 
    {
        const AutoStr2 * psTemp = pReq->getRealPath();
        if ( psTemp )
        {
            if (( type == REF_SCRIPT_BASENAME )||
                ( type == REF_REQ_BASENAME ))
            {
                const char * pEnd = psTemp->c_str() + psTemp->len();
                pValue = (char *)pEnd;
                while( pValue[-1] != '/' )
                    --pValue;
                return pEnd - pValue;
            }
            pValue = (char *)psTemp->c_str();
            return psTemp->len();
        }
        else
            return 0;
    }
    case REF_SCRIPT_UID:
    case REF_SCRIPT_GID:
    case REF_SCRIPT_USERNAME:
    case REF_SCRIPT_GRPNAME:
    case REF_SCRIPT_MODE:
    {
        const AutoStr2 * psTemp = pReq->getRealPath();
        if ( psTemp )
        {
            struct stat& st = pReq->getFileStat();
            if ( type == REF_SCRIPT_UID )
            {
                return snprintf( pValue, bufLen, "%d", st.st_uid );
            }
            else if ( type == REF_SCRIPT_GID )
            {
                return snprintf( pValue, bufLen, "%d", st.st_gid );
            }
            else if ( type == REF_SCRIPT_MODE )
            {
                return snprintf( pValue, bufLen, "%o", st.st_mode );
            }
            else if ( type == REF_SCRIPT_USERNAME )
            {
                struct passwd * pw = getpwuid( st.st_uid );
                if ( pw )
                    return snprintf( pValue, bufLen, "%s", pw->pw_name );
            }
            else
            {
                struct group * gr = getgrgid( st.st_gid );
                if ( gr )
                    return snprintf( pValue, bufLen, "%s", gr->gr_name );
            }
        }
        return 0;
    }
    case REF_PATH_INFO:
//.........这里部分代码省略.........
开发者ID:diegomontoya,项目名称:openlitespeed,代码行数:101,代码来源:requestvars.cpp

示例2: processRuleSet

int RewriteEngine::processRuleSet( const RewriteRuleList * pRuleList, HttpConnection * pConn,
            const HttpContext * pContext, const HttpContext * pRootContext )
{
    const RewriteRule * pRule = NULL;
    int loopCount = 0;
    int flag = 0;
    int ret;
    m_pContext = pContext;
    if ( pRuleList )
        pRule = pRuleList->begin();
    else
        pRule = getNextRule( NULL, pContext, pRootContext );
    if ( !pRule )
        return 0;
    HttpReq * pReq = pConn->getReq();
    const AutoStr2 * pBase = NULL;
    AutoStr2    sStrip;
    m_rewritten = 0;
    //initialize rewrite engine
    //strip prefix aka. RewriteBase
    m_logLevel = pReq->getRewriteLogLevel();
    m_pSourceURL = pReq->getURI();
    m_sourceURLLen = pReq->getURILen();
    m_pStrip = m_pBase = NULL;
    m_iScriptLen = -1;
    m_iPathInfoLen = 0;
    if ( m_pContext )
    {
        pBase = m_pContext->getContextURI();
        if (( pBase )&&
            ( strncmp( m_pSourceURL, pBase->c_str(), pBase->len() ) == 0 ))
        {
            m_pStrip = m_pBase = pBase;
        }
        else
        {
            m_pBase = pBase = m_pContext->getRewriteBase();
            if (( pBase )&&
                ( strncmp( m_pSourceURL, pBase->c_str(), pBase->len() ) == 0 ))
            {
                m_pStrip = m_pBase = pBase;
            }
            
        }
        
        if ( m_pContext->getRewriteBase() )
            m_pBase = m_pContext->getRewriteBase();
        if ( m_pStrip )
        {
            if ( m_logLevel > 4 )
                LOG_INFO(( pConn->getLogger(),
                        "[%s] [REWRITE] strip base: '%s' from URI: '%s'",
                        pConn->getLogId(), m_pStrip->c_str(), m_pSourceURL ));
            m_pSourceURL += m_pStrip->len();
            m_sourceURLLen -= m_pStrip->len();
        }
        else
        {
            if ( pConn->getReq()->isMatched() )
            {
                const char * pURL;
                int len;
                pConn->getReq()->stripRewriteBase( m_pContext,
                    pURL, len );
                if (( len < m_sourceURLLen )&&( strncmp( 
                        m_pSourceURL + m_sourceURLLen - len, pURL, len ) == 0 ))
                {
                    sStrip.setStr( m_pSourceURL, m_sourceURLLen - len );
                    m_pStrip = &sStrip;
                    if ( !m_pBase )
                        m_pBase = m_pStrip;
                }
                m_pSourceURL = pURL;
                m_sourceURLLen = len;
            }
        }
    }

    m_pQS = pReq->getQueryString();
    m_qsLen = pReq->getQueryStringLen();

    m_pOrgSourceURL = m_pSourceURL;
    m_orgSourceURLLen = m_sourceURLLen;

    m_condMatches = 0;
    m_pDestURLLen = 0;
    m_pDestURL = m_rewriteBuf[0];
    m_pCondBuf = m_rewriteBuf[1];
    m_pFreeBuf = m_rewriteBuf[2];
    m_action   = RULE_ACTION_NONE;
    m_flag     = 0;
    m_statusCode = 0;
    while( pRule )
    {
        flag = pRule->getFlag();
//        if (( flag & RULE_FLAG_NOSUBREQ )&&( pReq->isSubReq() > 0 ))
//            ret = -1;
//        else
            ret = processRule( pRule, pConn );
        if ( ret )
//.........这里部分代码省略.........
开发者ID:lsmichael,项目名称:openlitespeed,代码行数:101,代码来源:rewriteengine.cpp

示例3: buildReqHeader

int CgidConn::buildReqHeader()
{
    static unsigned int s_id = 0;
    HttpSession *pSession = getConnector()->getHttpSession();
    HttpReq * pReq = pSession->getReq();
    const char * pQueryString = pReq->getQueryString();
    const char * pQsEnd = pReq->getQueryString() + pReq->getQueryStringLen();
    const char * pReal;
    const AutoStr2 * psChroot;
    const AutoStr2 * realPath = pReq->getRealPath();
    const char * pChroot;
    int ret;
    uid_t uid;
    gid_t gid;
    pReal = realPath->c_str();
    ret = pReq->getUGidChroot( &uid, &gid, &psChroot );
    if ( ret )
        return ret;
//    if ( D_ENABLED( DL_LESS ) )
//        LOG_D(( getLogger(),
//            "[%s] UID: %d, GID: %d",
//            getLogId(), pHeader->m_uid, pHeader->m_gid ));
    if ( psChroot )
    {
//        if ( D_ENABLED( DL_LESS ) )
//            LOG_D(( getLogger(),
//                "[%s] chroot: %s, real path: %s",
//                getLogId(), pChroot->c_str(), pReal ));
        pChroot = psChroot->c_str();
        ret = psChroot->len();
    }
    else
    {
        pChroot = NULL;
        ret = 0;
    }
    int priority = ((CgidWorker *)getWorker())->getConfig().getPriority();
    m_req.buildReqHeader( uid, gid, priority, pChroot, ret, pReal,
                pReq->getRealPath()->len(),
                ((CgidWorker *)getWorker())->getConfig().getRLimits() );
    if ( *pQueryString && (memchr( pQueryString, '=',
                                pQsEnd - pQueryString ) == NULL ))
    {
        char * pPlus;
        do
        {
            pPlus = (char*)memchr( pQueryString, '+', pQsEnd - pQueryString);
            if ( pPlus != pQueryString )
            {
                int len;
                if ( pPlus )
                    len = pPlus - pQueryString;
                else
                    len = pQsEnd - pQueryString;
                m_req.appendArgv( pQueryString, len );
            }
            if ( pPlus )
                pQueryString = pPlus + 1;
        }while( pPlus );
    }
    m_req.appendArgv( NULL, 0 );

    HttpCgiTool::buildEnv( &m_req, pSession );

    m_req.finalize( s_id++, ((CgidWorker *)getWorker())->getConfig().getSecret(),
                    LSCGID_TYPE_CGI );
    return 0;
}
开发者ID:diegomontoya,项目名称:openlitespeed,代码行数:68,代码来源:cgidconn.cpp


注:本文中的HttpReq::getQueryStringLen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。