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


C++ HttpSession::getReq方法代码示例

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


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

示例1: addVar

int SSIEnv::addVar(int var_id)
{
    char achBuf[4096];
    const char *pName;
    int nameLen;
    pName = RequestVars::getVarNameStr(var_id, nameLen);
    if (!pName)
        return 0;
    char *pValue = achBuf;
    memccpy(pValue, m_pSession->getReq()->getSSIRuntime()
            ->getConfig()->getTimeFmt()->c_str(), 0, 4096);
    int valLen = RequestVars::getReqVar(m_pSession, var_id, pValue, 4096);
    return add(pName, nameLen, pValue, valLen);
}
开发者ID:52M,项目名称:openlitespeed,代码行数:14,代码来源:ssiengine.cpp

示例2: HioChainStream

HttpSession *HttpSession::newSubSession(SubSessInfo_t *pSubSessInfo)
{
    //for subsession, we intentionally turn off
    //   keepalive
    //   chunk
    //   gzip compression
    //   security

    //detect loop subsessions
    int depth = 1;
    if (m_pParent)
    {
        depth = 1 + ((HioChainStream *)getStream())->getDepth();
        if (depth > 9)
            return NULL;
    }

    if (detectLoopSubSession(pSubSessInfo) == 1)
        return NULL;

    HttpSession *pSession = HttpSessionPool::getSession();
    if (! pSession)
        return NULL;

    //pSession->setSsiRuntime( m_pSsiRuntime );
    HioChainStream *pStream = new HioChainStream();
    pStream->setHandler(pSession);
    pSession->setStream(pStream);
    pSession->getReq()->setILog(pStream);
    pSession->m_pClientInfo = m_pClientInfo;
    pSession->m_pSslConn = m_pSslConn;

    pStream->setDepth(depth);

    pSession->getReq()->setMethod(pSubSessInfo->m_method);
    if (pSession->getReq()->clone(getReq(), pSubSessInfo))
    {
        pStream->setHandler(NULL);
        delete pStream;
        HttpSessionPool::recycle(pSession);
        return NULL;
    }

    pSession->setFlag(HSF_SEC_CLEARED | HSF_SEC_RESP_CLEARED |
                      HSF_SUB_SESSION);
    pSession->getResp()->reset();

#ifdef _ENTERPRISE_
    pSession->getResp()->setCacheStore(getCacheStore());
#endif

    LS_DBG_M(getLogSession(), "Create SUB SESSION: %d, flag: %d, "
             "method: %s, URI: %s, len: %d, QS: %s, len: %d",
             m_iSubReqSeq, pSubSessInfo->m_flag,
             HttpMethod::get(pSubSessInfo->m_method),
             pSubSessInfo->m_cacheKey.m_pUri,
             pSubSessInfo->m_cacheKey.m_iUriLen,
             pSubSessInfo->m_cacheKey.m_pQs ? pSubSessInfo->m_cacheKey.m_pQs : "",
             pSubSessInfo->m_cacheKey.m_iQsLen);
    HttpSession *parent = NULL;
    if (pSubSessInfo->m_flag & SUB_REQ_DETACHED)
    {
        pStream->setParentSession(NULL);
        //set Stream to black hole mode,
        pStream->setFlag(HIO_FLAG_BLACK_HOLE, 1);
        //parent = getBackGroundSession();

    }
    else
    {
        pStream->setSequence(m_iSubReqSeq++);

        parent = this;
    }

    if (pSubSessInfo->m_flag & SUB_REQ_NOABORT)
        pSession->setFlag(HSF_NO_ABORT, 1);

    if (pSubSessInfo->m_flag & SUB_REQ_NOCACHE)
        pSession->setFlag(HSF_NOCACHE, 1);

    pSession->m_pParent = parent;

    return pSession;
}
开发者ID:kopytov,项目名称:openlitespeed,代码行数:85,代码来源:subrequest.cpp

示例3: buildSSIExecHeader

int CgidConn::buildSSIExecHeader()
{
    static unsigned int s_id = 0;
    HttpSession *pSession = getConnector()->getHttpSession();
    HttpReq * pReq = pSession->getReq();
    const char * pReal;
    const AutoStr2 * psChroot;
    const char * pChroot;
    int ret;
    uid_t uid;
    gid_t gid;
    pReal = pReq->getRealPath()->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;
    }
    char achBuf[4096];
    memccpy( achBuf, pReal, 0, 4096 );
    char * argv[256];
    char ** p;
    char * pDir ;
    SUExec::buildArgv( achBuf, &pDir, argv, 256 );
    if ( pDir )
        *(argv[0]-1) = '/';
    else
        pDir = argv[0];

    int priority = ((CgidWorker *)getWorker())->getConfig().getPriority();
    m_req.buildReqHeader( uid, gid, priority, pChroot, ret, pDir,
                strlen( pDir ),
                ((CgidWorker *)getWorker())->getConfig().getRLimits() );
    p = &argv[1];
    while( *p )
    {
        m_req.appendArgv( *p, strlen( *p ) );
        ++p;
    }
    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,代码行数:62,代码来源:cgidconn.cpp

示例4: 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

示例5: sendReqHeader

int ProxyConn::sendReqHeader()
{
    m_iovec.clear();
    HttpSession *pSession = getConnector()->getHttpSession();
    HttpReq *pReq = pSession->getReq();
    //remove the trailing "\r\n" before adding our headers
    const char *pBegin = pReq->getOrgReqLine();
    m_iTotalPending = pReq->getHttpHeaderLen();
    int newReqLineLen = 0;
    int headerLen = 17;
    char *pExtraHeader = &m_extraHeader[23];
    const char *pForward = pReq->getHeader(HttpHeader::H_X_FORWARDED_FOR);
    int len;
    if (*pForward != '\0')
    {
        len = pReq->getHeaderLen(HttpHeader::H_X_FORWARDED_FOR);
        if (len > 160)
            len = 160;
        memmove(&pExtraHeader[headerLen], pForward, len);
        headerLen += len;
        pExtraHeader[headerLen++] = ',';

    }
    //add "X-Forwarded-For" header
    memmove(&pExtraHeader[headerLen], pSession->getPeerAddrString(),
            pSession->getPeerAddrStrLen());
    headerLen += pSession->getPeerAddrStrLen();
    pExtraHeader[headerLen++] = '\r';
    pExtraHeader[headerLen++] = '\n';

#if 1       //always set "Accept-Encoding" header to "gzip"
    char *pAE = (char *)pReq->getHeader(HttpHeader::H_ACC_ENCODING);
    if (*pAE)
    {
        int len = pReq->getHeaderLen(HttpHeader::H_ACC_ENCODING);
        if (len >= 4)
        {
            memmove(pAE, "gzip", 4);
            memset(pAE + 4, ' ', len - 4);
        }
    }
    else
    {
        pExtraHeader = m_extraHeader;
        headerLen += 23;
    }
#endif

    if (*(pBegin + --m_iTotalPending - 1) == '\r')
        --m_iTotalPending;
    if (*pForward)
    {
        if ((pBegin + m_iTotalPending) -
            (pForward + pReq->getHeaderLen(HttpHeader::H_X_FORWARDED_FOR)) == 2)
        {
            const char *p = pForward -= 16;
            while (*(p - 1) != '\n')
                --p;
            m_iTotalPending = p - pBegin;
        }
    }

    //reconstruct request line if URL has been rewritten
    if (pReq->getRedirects() > 0)
    {
        const char *pReqLine = pReq->encodeReqLine(newReqLineLen);
        if (newReqLineLen > 0)
        {
            m_iovec.append(pReqLine, newReqLineLen);
            pBegin += pReq->getOrgReqLineLen() - 9;
            m_iTotalPending -= pReq->getOrgReqLineLen() - 9;
        }

    }

    int newHostLen = pReq->getNewHostLen();
    char *pHost = (char *)pReq->getHeader(HttpHeader::H_HOST);
    int hostLen = pReq->getHeaderLen(HttpHeader::H_HOST);
    if (newHostLen > 0)
    {
        if (*pHost)
        {
            m_iovec.append(pBegin, pHost - pBegin);
            m_iovec.append(pReq->getNewHost(), newHostLen);
            m_iovec.append(pHost + hostLen,
                           pBegin + m_iTotalPending - pHost - hostLen);
            m_iTotalPending += (newHostLen - hostLen);
        }
        else
        {
            m_iovec.append(pBegin, m_iTotalPending);
            m_iovec.append("Host: ", 6);
            m_iovec.append(pReq->getNewHost(), newHostLen);
            m_iovec.append("\r\n", 2);
            m_iTotalPending += newHostLen + 8;
        }
    }
    else
        m_iovec.append(pBegin, m_iTotalPending);
    m_iTotalPending += newReqLineLen;
//.........这里部分代码省略.........
开发者ID:52M,项目名称:openlitespeed,代码行数:101,代码来源:proxyconn.cpp


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