mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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
Notes:
sideshowbarker
2024-07-17 02:57:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6d1db6801c Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
1 changed files with 7 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "RequestManagerQt.h"
|
||||
#include <AK/JsonObject.h>
|
||||
#include <QNetworkCookie>
|
||||
|
||||
RequestManagerQt::RequestManagerQt()
|
||||
{
|
||||
|
@ -81,7 +82,12 @@ void RequestManagerQt::Request::did_finish()
|
|||
auto name = String(it.first.data(), it.first.length());
|
||||
auto value = String(it.second.data(), it.second.length());
|
||||
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 {
|
||||
response_headers.set(name, value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue