mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 10:07:43 +00:00
Ladybird/RequestManagerQt: Unwrap multiple cookies masquerading as one
Qt can wrap any number of cookies into a single Set-Cookie header in the network responses it gives us. We now use the QNetworkReply::header() API to get a "cooked" list of the cookies, and then rewrap them in a format suitable for LibWeb. Sites that send multiple Set-Cookie headers in one response now work a lot better. :^)
This commit is contained in:
parent
195cdb33de
commit
6d1db6801c
1 changed files with 7 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "RequestManagerQt.h"
|
#include "RequestManagerQt.h"
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
|
#include <QNetworkCookie>
|
||||||
|
|
||||||
RequestManagerQt::RequestManagerQt()
|
RequestManagerQt::RequestManagerQt()
|
||||||
{
|
{
|
||||||
|
@ -81,7 +82,12 @@ void RequestManagerQt::Request::did_finish()
|
||||||
auto name = String(it.first.data(), it.first.length());
|
auto name = String(it.first.data(), it.first.length());
|
||||||
auto value = String(it.second.data(), it.second.length());
|
auto value = String(it.second.data(), it.second.length());
|
||||||
if (name.equals_ignoring_case("set-cookie"sv)) {
|
if (name.equals_ignoring_case("set-cookie"sv)) {
|
||||||
set_cookie_headers.append(value);
|
// NOTE: Qt may have bundled multiple Set-Cookie headers into a single one.
|
||||||
|
// We have to extract the full list of cookies via QNetworkReply::header().
|
||||||
|
auto set_cookie_list = m_reply.header(QNetworkRequest::SetCookieHeader).value<QList<QNetworkCookie>>();
|
||||||
|
for (auto const& cookie : set_cookie_list) {
|
||||||
|
set_cookie_headers.append(cookie.toRawForm().data());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
response_headers.set(name, value);
|
response_headers.set(name, value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue