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


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

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


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

示例1: getReqVar


//.........这里部分代码省略.........
        i = StringTool::str_off_t( pValue, bufLen, pSession->getResp()->getBodySent() );
        return i;
    //case REF_COOKIE_VAL
    //case REF_STRFTIME        155
    //case REF_CONN_STATE:
    case REF_REQ_TIME_MS:
    {
        struct timeval tv;
        gettimeofday( &tv, NULL );
        DateTime::s_curTime = tv.tv_sec;
        DateTime::s_curTimeUs = tv.tv_usec;

        long lReqTime =  (DateTime::s_curTime - pSession->getReqTime())*1000000 +
                    (DateTime::s_curTimeUs - pSession->getReqTimeUs());
        i = snprintf( pValue, bufLen, "%ld", lReqTime );
        return i;
    }
    case REF_REQ_TIME_SEC:
        i = snprintf( pValue, bufLen, "%ld",
                    (DateTime::s_curTime - pSession->getReqTime()) );
        return i;
    case REF_DUMMY:
        return 0;
    case REF_PID:
        i = snprintf( pValue, bufLen, "%d", getpid() );
        return i;
    case REF_STATUS_CODE:
        memmove( pValue, HttpStatusCode::getCodeString( pReq->getStatusCode() )+1, 3 );
        pValue[3] = 0;
        return 3;
    
    case REF_CUR_URI:
        pValue = (char *)pReq->getURI();
        i = pReq->getURILen();
        return i;
    case REF_BYTES_IN:
        i = StringTool::str_off_t( pValue, bufLen, pSession->getBytesRecv() );
        return i;
    case REF_BYTES_OUT:
        i = StringTool::str_off_t( pValue, bufLen, pSession->getBytesSent() );
        return i;

    case REF_HTTPS:
        i = snprintf( pValue, bufLen, "%s", pSession->isSSL()?"on":"off" );
        return i;

    case REF_DATE_GMT:
    case REF_DATE_LOCAL:
    case REF_LAST_MODIFIED:
    {
        time_t mtime = DateTime::s_curTime;
        struct tm * tm;
        if ( type == REF_LAST_MODIFIED )
        {
            if ( pReq->getSSIRuntime() && pReq->getSSIRuntime()->getCurrentScript() )
            {
                mtime = pReq->getSSIRuntime()->getCurrentScript()->getLastMod();
            }
            else
                mtime = pReq->getFileStat().st_mtime;
        }
        if ( type == REF_DATE_GMT )
            tm = gmtime( &mtime );
        else
            tm = localtime( &mtime );
        char fmt[101]; 
开发者ID:diegomontoya,项目名称:openlitespeed,代码行数:67,代码来源: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: processSubReq

int SSIEngine::processSubReq(HttpSession *pSession, SubstItem *pItem)
{
    char achBuf[40960];
    char *p;
    int len;
    int attr;
    if (!pItem)
        return 0;
    SSIRuntime *pRuntime = pSession->getReq()->getSSIRuntime();
    attr = pItem->getSubType();
    p = achBuf;
    len = 40960;
    switch (attr)
    {
    case SSI_INC_FILE:
        {
            HttpReq *pReq = pSession->getReq();
            memmove(p, pReq->getURI(), pReq->getURILen());
            p = p + pReq->getURILen() - pReq->getPathInfoLen();
            while (p[-1] != '/')
                --p;
            *p = 0;
            len -= p - achBuf;
            break;
        }
    case SSI_EXEC_CGI:
        pRuntime->requireCGI();
        break;
    case SSI_EXEC_CMD:
        pRuntime->requireCmd();
        p += snprintf(achBuf, 40960, "%s",
                      pRuntime->getCurrentScript()->getPath());
        while (p[-1] != '/')
            --p;
        *p++ = '&';
        *p++ = ' ';
        *p++ = '-';
        *p++ = 'c';
        *p++ = ' ';
        len -= p - achBuf;
        // make the command looks like "/script/path/& command"
        // '&' tell cgid to execute it as shell command
        break;
    }
    RequestVars::appendSubst(pItem, pSession, p, len,
                             0, pRuntime->getRegexResult());
    if (attr == SSI_INC_FILE)
    {
        if (strstr(achBuf, "/../") != NULL)

            return 0;
    }
    else if (attr == SSI_EXEC_CMD)
    {

        if (pSession->execExtCmd(achBuf, p - achBuf) == 0)
            return -2;
        else
            return 0;
        //len = snprintf( achBuf, 40960, "'exec cmd' is not available, "
        //            "use 'include virutal' instead.\n" );
        //pSession->appendDynBody( achBuf, len );

        //return 0;
    }
    if ((achBuf[0] != '/') && (attr != SSI_EXEC_CMD))
    {
        if (achBuf[0] == 0)
        {
            len = snprintf(achBuf, 40960,
                           "[an error occurred while processing this directive]\n");
            pSession->appendDynBody(achBuf, len);
            return 0;
        }
        HttpReq *pReq = pSession->getReq();
        const char *pURI = pReq->getURI();
        const char *p1 = pURI + pReq->getURILen() - pReq->getPathInfoLen();
        while ((p1 > pURI) && p1[-1] != '/')
            --p1;
        int prefix_len = p1 - pURI;
        memmove(&achBuf[prefix_len], achBuf, p - achBuf);
        memmove(achBuf, pReq->getURI(), prefix_len);
        p += prefix_len;
    }
    if (achBuf[0] == '/')
    {
        pSession->getReq()->setLocation(achBuf, p - achBuf);
        pSession->changeHandler();
        pSession->continueWrite();
        return -2;
    }
    return 0;
}
开发者ID:52M,项目名称:openlitespeed,代码行数:93,代码来源:ssiengine.cpp


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