Fix the "map/set iterators incompatible" bug.

cookies is only valid when AIHTTPReceivedHeaders::getValues return true.
This commit is contained in:
Aleric Inglewood
2013-01-12 04:24:14 +01:00
parent e56f14502e
commit 024c62aed4
2 changed files with 11 additions and 7 deletions

View File

@@ -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)
{
AIHTTPReceivedHeaders::range_type cookies;
mReceivedHeaders.getValues("set-cookie", cookies);
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
if (mReceivedHeaders.getValues("set-cookie", cookies))
{
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.

View File

@@ -158,10 +158,12 @@ public:
// Erase all headers EXCEPT the cookies.
AIHTTPReceivedHeaders set_cookie_headers;
AIHTTPReceivedHeaders::range_type cookies;
mReceivedHeaders.getValues("set-cookie", cookies);
for (AIHTTPReceivedHeaders::iterator_type cookie = cookies.first; cookie != cookies.second; ++cookie)
if (mReceivedHeaders.getValues("set-cookie", cookies))
{
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.
mReceivedHeaders.swap(set_cookie_headers);