2021-04-14 14:34:18 +00:00
|
|
|
/*
|
2022-01-31 18:07:22 +00:00
|
|
|
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
2021-04-14 14:34:18 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-14 14:34:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LoadRequest.h"
|
|
|
|
#include <LibWeb/Cookie/Cookie.h>
|
|
|
|
#include <LibWeb/Page/Page.h>
|
|
|
|
|
|
|
|
namespace Web {
|
|
|
|
|
2024-05-26 11:52:39 +00:00
|
|
|
static int s_resource_id = 0;
|
|
|
|
|
|
|
|
LoadRequest::LoadRequest()
|
|
|
|
: m_id(s_resource_id++)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
LoadRequest LoadRequest::create_for_url_on_page(const URL::URL& url, Page* page)
|
2021-04-14 14:34:18 +00:00
|
|
|
{
|
|
|
|
LoadRequest request;
|
|
|
|
request.set_url(url);
|
|
|
|
|
|
|
|
if (page) {
|
2024-01-26 16:10:15 +00:00
|
|
|
auto cookie = page->client().page_did_request_cookie(url, Cookie::Source::Http);
|
2021-04-14 14:34:18 +00:00
|
|
|
if (!cookie.is_empty())
|
2024-01-26 16:10:15 +00:00
|
|
|
request.set_header("Cookie", cookie.to_byte_string());
|
2022-02-26 16:50:31 +00:00
|
|
|
request.set_page(*page);
|
2021-04-14 14:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|