mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb/Fetch: Handle streams on abort
When aborting fetch, the request stream now gets closed and the response stream errors.
This commit is contained in:
parent
b263cd11f7
commit
e18fb7fc93
Notes:
github-actions[bot]
2024-12-16 11:44:14 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e18fb7fc930 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1871 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/BroadbentJim
1 changed files with 4 additions and 4 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <LibWeb/Fetch/Request.h>
|
||||
#include <LibWeb/Fetch/Response.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
|
@ -163,8 +164,8 @@ void abort_fetch(JS::Realm& realm, WebIDL::Promise const& promise, GC::Ref<Infra
|
|||
|
||||
// 2. If request’s body is non-null and is readable, then cancel request’s body with error.
|
||||
if (auto* body = request->body().get_pointer<GC::Ref<Infrastructure::Body>>(); body != nullptr && (*body)->stream()->is_readable()) {
|
||||
// TODO: Implement cancelling streams
|
||||
(void)error;
|
||||
// NOTE: Cancel here is different than the cancel method of stream and refers to https://streams.spec.whatwg.org/#readablestream-cancel
|
||||
Streams::readable_stream_cancel((*body)->stream(), error);
|
||||
}
|
||||
|
||||
// 3. If responseObject is null, then return.
|
||||
|
@ -178,8 +179,7 @@ void abort_fetch(JS::Realm& realm, WebIDL::Promise const& promise, GC::Ref<Infra
|
|||
if (response->body()) {
|
||||
auto stream = response->body()->stream();
|
||||
if (stream->is_readable()) {
|
||||
// TODO: Implement erroring streams
|
||||
(void)error;
|
||||
stream->error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue