Fix the "map/set iterators incompatible" bug.
cookies is only valid when AIHTTPReceivedHeaders::getValues return true.
This commit is contained in:
@@ -370,12 +370,14 @@ void LLHTTPClient::ResponderBase::decode_raw_body(U32 status, std::string const&
|
|||||||
std::string const& LLHTTPClient::ResponderBase::get_cookie(std::string const& key)
|
std::string const& LLHTTPClient::ResponderBase::get_cookie(std::string const& key)
|
||||||
{
|
{
|
||||||
AIHTTPReceivedHeaders::range_type cookies;
|
AIHTTPReceivedHeaders::range_type cookies;
|
||||||
mReceivedHeaders.getValues("set-cookie", cookies);
|
if (mReceivedHeaders.getValues("set-cookie", cookies))
|
||||||
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
|
|
||||||
{
|
{
|
||||||
if (key == cookie->second.substr(0, cookie->second.find('=')))
|
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
|
||||||
{
|
{
|
||||||
return cookie->second;
|
if (key == cookie->second.substr(0, cookie->second.find('=')))
|
||||||
|
{
|
||||||
|
return cookie->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not found.
|
// Not found.
|
||||||
|
|||||||
@@ -158,10 +158,12 @@ public:
|
|||||||
// Erase all headers EXCEPT the cookies.
|
// Erase all headers EXCEPT the cookies.
|
||||||
AIHTTPReceivedHeaders set_cookie_headers;
|
AIHTTPReceivedHeaders set_cookie_headers;
|
||||||
AIHTTPReceivedHeaders::range_type cookies;
|
AIHTTPReceivedHeaders::range_type cookies;
|
||||||
mReceivedHeaders.getValues("set-cookie", cookies);
|
if (mReceivedHeaders.getValues("set-cookie", cookies))
|
||||||
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
|
|
||||||
{
|
{
|
||||||
set_cookie_headers.addHeader(cookie->first, cookie->second);
|
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
|
||||||
|
{
|
||||||
|
set_cookie_headers.addHeader(cookie->first, cookie->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Replace headers with just the cookie headers.
|
// Replace headers with just the cookie headers.
|
||||||
mReceivedHeaders.swap(set_cookie_headers);
|
mReceivedHeaders.swap(set_cookie_headers);
|
||||||
|
|||||||
Reference in New Issue
Block a user