mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
LibWeb: Pass optional status code to ResourceLoader callbacks
This is needed for XMLHttpRequest, and will certainly be useful for other things, too.
This commit is contained in:
parent
975b209b9b
commit
000ef96613
8 changed files with 42 additions and 39 deletions
|
@ -85,11 +85,12 @@ static String mime_type_from_content_type(const String& content_type)
|
|||
return content_type;
|
||||
}
|
||||
|
||||
void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers)
|
||||
void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers, Optional<u32> status_code)
|
||||
{
|
||||
VERIFY(!m_loaded);
|
||||
m_encoded_data = ByteBuffer::copy(data);
|
||||
m_response_headers = headers;
|
||||
m_status_code = move(status_code);
|
||||
m_loaded = true;
|
||||
|
||||
auto content_type = headers.get("Content-Type");
|
||||
|
@ -116,9 +117,10 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
|
|||
});
|
||||
}
|
||||
|
||||
void Resource::did_fail(Badge<ResourceLoader>, const String& error)
|
||||
void Resource::did_fail(Badge<ResourceLoader>, const String& error, Optional<u32> status_code)
|
||||
{
|
||||
m_error = error;
|
||||
m_status_code = move(status_code);
|
||||
m_failed = true;
|
||||
|
||||
for_each_client([](auto& client) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue