本文整理汇总了C++中HttpReq::getOrgReqLineLen方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getOrgReqLineLen方法的具体用法?C++ HttpReq::getOrgReqLineLen怎么用?C++ HttpReq::getOrgReqLineLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpReq
的用法示例。
在下文中一共展示了HttpReq::getOrgReqLineLen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log
void AccessLog::log( HttpConnection* pConn )
{
int n;
HttpReq* pReq = pConn->getReq();
HttpResp* pResp = pConn->getResp();
const char * pUser = pReq->getAuthUser();
long contentWritten = pResp->getBodySent();
const ClientInfo * pInfo = pConn->getClientInfo();
const char * pAddr = pInfo->getHostName();
pResp->needLogAccess( 0 );
if ( m_iPipedLog )
{
if ( !m_pManager )
return;
m_pAppender = m_pManager->getAppender();
if ( !m_pAppender )
return;
}
if ( m_pCustomFormat )
return customLog( pConn );
if (( pAddr )&&( *pAddr ))
{
n = pInfo->getHostNameLen();
}
else
{
pAddr = pInfo->getAddrString();
n = pInfo->getAddrStrLen();
}
m_buf.appendNoCheck( pAddr, n );
if ( ! *pUser )
{
m_buf.appendNoCheck( " - - ", 5 );
}
else
{
n = safe_snprintf( m_buf.end(), 70, " - \"%s\" ", pUser );
m_buf.used( n );
}
DateTime::getLogTime( pConn->getReqTime(), m_buf.end() );
m_buf.used( 30 );
n = pReq->getOrgReqLineLen();
char * pOrgReqLine = (char *)pReq->getOrgReqLine();
if ( pReq->getVersion() == HTTP_1_0 )
*(pOrgReqLine + n - 1) = '0';
if (( n > 4096 )||( m_buf.available() < 100 + n ))
{
flush();
m_pAppender->append( pOrgReqLine, n );
}
else
m_buf.appendNoCheck(pOrgReqLine, n );
m_buf.append( '"' );
m_buf.appendNoCheck(
HttpStatusCode::getCodeString( pReq->getStatusCode() ), 5 );
if ( contentWritten == 0 )
{
m_buf.append( '-' );
}
else
{
n = safe_snprintf( m_buf.end(), 20, "%ld", contentWritten );
m_buf.used( n );
}
if ( getAccessLogHeader() & LOG_REFERER )
{
m_buf.append( ' ' );
appendStr( pReq->getHeader( HttpHeader::H_REFERER ),
pReq->getHeaderLen( HttpHeader::H_REFERER ));
}
if ( getAccessLogHeader() & LOG_USERAGENT )
{
m_buf.append( ' ' );
appendStr( pReq->getHeader( HttpHeader::H_USERAGENT),
pReq->getHeaderLen( HttpHeader::H_USERAGENT) );
}
if ( getAccessLogHeader() & LOG_VHOST )
{
m_buf.append( ' ' );
appendStr( pReq->getHeader( HttpHeader::H_HOST ),
pReq->getHeaderLen( HttpHeader::H_HOST ) );
}
m_buf.append( '\n' );
if (( m_buf.available() < MAX_LOG_LINE_LEN )
||!asyncAccessLog() )
{
flush();
}
}
示例2: getReqVar
//.........这里部分代码省略.........
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();
return pReq->getLocalAddrStr()->len();
case REF_SERVER_PORT:
pValue = (char *)pReq->getPortStr().c_str();
return pReq->getPortStr().len();
case REF_SERVER_PROTO:
i = pReq->getVersion();
pValue = (char *)HttpVer::getVersionString( i );
return HttpVer::getVersionStringLen( i );
case REF_SERVER_SOFT:
pValue = (char *)HttpServerVersion::getVersion();
return HttpServerVersion::getVersionLen();
case REF_REQ_LINE:
pValue = (char *)pReq->getOrgReqLine();
return pReq->getOrgReqLineLen();
case REF_IS_SUBREQ:
strcpy( pValue, "false" );
return 5;
case REF_RESP_BYTES:
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:
示例3: 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;
//.........这里部分代码省略.........