本文整理汇总了C++中HTTPRequest::read方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPRequest::read方法的具体用法?C++ HTTPRequest::read怎么用?C++ HTTPRequest::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
TEST(HTTPRequest, testInvalid3)
{
std::string s("GET / HTTP/1.10");
std::istringstream istr(s);
HTTPRequest request;
EXPECT_THROW(request.read(istr), MessageException);
}
示例2: s
void HTTPRequestTest::testRead1()
{
std::string s("GET / HTTP/1.0\r\n\r\n");
std::istringstream istr(s);
HTTPRequest request;
request.read(istr);
assert (request.getMethod() == HTTPRequest::HTTP_GET);
assert (request.getURI() == "/");
assert (request.getVersion() == HTTPMessage::HTTP_1_0);
assert (request.empty());
assert (istr.get() == -1);
}
示例3: FromAceHeader
SiriTokenProvider::Ptr SiriTokenProvider::FromAceHeader( const string& header )
{
SiriTokenProvider::Ptr p=new SiriTokenProvider();
p->m_http_string=header;
if(p->m_http_string.find("Assistant(iPhone/iPhone4,1;")!=-1)
{
stringstream ss(p->m_http_string);
HTTPRequest req;
req.read(ss);
if(req.has("X-Ace-Host"))
{
p->m_Ticket.x_ace_host=req["X-Ace-Host"];
}
if(req.has("User-Agent"))
{
p->m_Ticket.user_agent=req["User-Agent"];
}
p->iPhone4s=true;
p->m_Ticket.iPhone4s=true;
if(!p->CheckHeader())
{
delete p;
return NULL;
}
}
else
{
p->m_http_string=iPhone4s_header_tmpl;
p->iPhone4s=false;
p->m_Ticket.iPhone4s=false;
if(!p->CheckHeader())
{
delete p;
return NULL;
}
stringstream ss(p->m_http_string);
HTTPRequest req;
req.read(ss);
string strAceHost;
size_t offset=p->m_http_string.find("X-Ace-Host");
if(offset!=-1)
{
size_t n1=p->m_http_string.find(":",offset);
if(n1==(offset+strlen("X-Ace-Host")))
{
size_t n2=p->m_http_string.find("\r\n",n1);
if(n2>n1)
{
string ace_host=p->m_http_string.substr(n1+1,n2-n1);
p->m_Ticket.x_ace_host=ace_host;
strAceHost=ace_host;
}
}
}
if(req.has("X-Ace-Host"))
{
strAceHost==req.get("X-Ace-Host");
if(!strAceHost.empty())
p->m_Ticket.x_ace_host=strAceHost;
}
p->m_Ticket.x_ace_host_tmpl=p->m_Ticket.x_ace_host;
if(!SiriTokenProvider::GetNextTicket(&p->m_Ticket))
{
delete p;
return NULL;
}
p->m_http_string=Poco::replace(p->m_http_string,strAceHost,p->m_Ticket.x_ace_host);
p->m_http_string=Poco::replace(p->m_http_string,"siri.cd-team.org","guzzoni.apple.com");
}
return p;
}