本文整理汇总了C++中HttpSession::getPeerAddrStrLen方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpSession::getPeerAddrStrLen方法的具体用法?C++ HttpSession::getPeerAddrStrLen怎么用?C++ HttpSession::getPeerAddrStrLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpSession
的用法示例。
在下文中一共展示了HttpSession::getPeerAddrStrLen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........