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


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

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


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

示例1: processHeaderLine

int HttpCgiTool::processHeaderLine( HttpExtConnector * pExtConn, const char * pLineBegin,
                                const char * pLineEnd, int &status )
{
    int index;
    const char * pKeyEnd;
    const char * pValue = pLineBegin;
    char * p;
    HttpResp* pResp = pExtConn->getHttpConn()->getResp();
    HttpReq * pReq = pExtConn->getHttpConn()->getReq();
    
    index = HttpHeader::getRespHeaderIndex( pValue );
    if ( index < HttpHeader::H_HEADER_END )
    {
        pValue += HttpHeader::getHeaderStringLen( index );

        while( isspace(*pValue) )
            ++pValue;
        pKeyEnd = pValue;
        if ( *pValue != ':' )
        {
            index = HttpHeader::H_HEADER_END;
        }
        else
        {
            do { ++pValue; }
            while( isspace(*pValue) );
        }
    }
    if ( index == HttpHeader::H_HEADER_END )
    {
        pKeyEnd = (char *)memchr( pValue, ':', pLineEnd - pValue );
        if ( pKeyEnd != NULL )
        {
            pValue = pKeyEnd + 1;
            while( isspace(*pValue) )
                ++pValue;
        }
        else
        {
            if ( !isspace( *pLineBegin ) )
                return 0;
        }
    }
    switch( index )
    {
    case HttpHeader::H_CONTENT_TYPE:
        p = (char *)memchr( pValue, ';', pLineEnd - pValue );
        if ( pReq->gzipAcceptable() )
        {
            register char ch = 0;
            register char *p1;
            if ( p )
            {
                p1 = (char*)p;
            }
            else
                p1 = (char*)pLineEnd;
            ch = *p1;
            *p1 = 0;
            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
//.........这里部分代码省略.........
开发者ID:DSpeichert,项目名称:OpenLiteSpeed,代码行数:101,代码来源:httpcgitool.cpp

示例2: processHeaderLine

int HttpCgiTool::processHeaderLine(HttpExtConnector *pExtConn,
                                   const char  *pLineBegin,
                                   const char *pLineEnd, int &status)
{
    HttpRespHeaders::HEADERINDEX index;
    int tmpIndex;
    const char *pKeyEnd = NULL;
    const char *pValue = pLineBegin;
    char *p;
    HttpResp *pResp = pExtConn->getHttpSession()->getResp();
    HttpReq *pReq = pExtConn->getHttpSession()->getReq();

    index = HttpRespHeaders::getRespHeaderIndex(pValue);
    if (index < HttpRespHeaders::H_HEADER_END)
    {
        pValue += HttpRespHeaders::getHeaderStringLen(index);

        while (isspace(*pValue))
            ++pValue;
        pKeyEnd = pValue;
        if (*pValue != ':')
            index = HttpRespHeaders::H_HEADER_END;
        else
        {
            do { ++pValue; }
            while (isspace(*pValue));
        }
    }
    if (index == HttpRespHeaders::H_HEADER_END)
    {
        pKeyEnd = (char *)memchr(pValue, ':', pLineEnd - pValue);
        if (pKeyEnd != NULL)
        {
            pValue = pKeyEnd + 1;
            while (isspace(*pValue))
                ++pValue;
        }
        else
        {
            if (!isspace(*pLineBegin))
                return 0;
        }
    }
    switch (index)
    {
    case HttpRespHeaders::H_CONTENT_TYPE:
        if (pReq->getStatusCode() == SC_304)
            return 0;
        p = (char *)memchr(pValue, ';', pLineEnd - pValue);
        if (pReq->gzipAcceptable() == GZIP_REQUIRED)
        {
            char ch = 0;
            char *p1;
            if (p)
                p1 = (char *)p;
            else
                p1 = (char *)pLineEnd;
            ch = *p1;
            *p1 = 0;
            if (!HttpMime::getMime()->compressible(pValue))
                pReq->andGzip(~GZIP_ENABLED);
            *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;
            }
            HttpRespHeaders &buf = pResp->getRespHeaders();
            AutoStr2 str = "";
            str.append(pLineBegin, pLineEnd - pLineBegin);
            str.append(pCharset->c_str(), pCharset->len());
            str.append("\r\n", 2);
            buf.parseAdd(str.c_str(), str.len(), LSI_HEADEROP_ADD);
        }
        return 0;
    case HttpRespHeaders::H_CONTENT_ENCODING:
        if (pReq->getStatusCode() == SC_304)
            return 0;
        if (strncasecmp(pValue, "gzip", 4) == 0)
            pReq->orGzip(UPSTREAM_GZIP);
        else if (strncasecmp(pValue, "deflate", 7) == 0)
            pReq->orGzip(UPSTREAM_DEFLATE);
//             if ( !(pReq->gzipAcceptable() & REQ_GZIP_ACCEPT) )
//                 return 0;
//         }
//         else //if ( strncasecmp( pValue, "deflate", 7 ) == 0 )
//         {
//             pReq->andGzip( ~GZIP_ENABLED );
//         }
//.........这里部分代码省略.........
开发者ID:creativeprogramming,项目名称:openlitespeed,代码行数:101,代码来源:httpcgitool.cpp


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