summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Fetch
AgeCommit message (Collapse)Author
2023-03-06LibWeb: Fix a few const-ness issuesMatthew Olsson
2023-03-06LibJS: Handle both const and non-const Ts in Handle<T>::create()Matthew Olsson
Again, the const-ness only really involves Heap-internal metadata, so the callers shouldn't care about mutations here.
2023-03-03LibWeb/Fetch: Store Response error message as a String{,View} variantLinus Groh
The majority of error strings are StringView literals, and it seems silly to require heap-allocating strings for these. This idea is stolen from a recent change in fd1fbad :^)
2023-03-03LibWeb/Fetch: Propagate OOM errors from HeaderList::extract_mime_type()Linus Groh
2023-03-03LibWeb/MimeSniff: Port MimeType to new StringLinus Groh
2023-03-03LibWeb/MimeSniff: Rename MimeType::from_string() to MimeType::parse()Linus Groh
This matches the spec's "parse a MIME type".
2023-03-03LibWeb/Fetch: Port infrastructure to new StringLinus Groh
2023-03-03LibWeb/Fetch: Port JS interfaces to new StringLinus Groh
Since BodyInit and Headers are tightly coupled to both Request and Response, I chose to do all of them at once instead of introducing a bunch of temporary conversion glue code.
2023-03-01LibWeb: Port URL and URLSearchParams to new StringKenneth Myhra
2023-02-26LibWeb: Port IDL implementations Blob and File to new StringKenneth Myhra
2023-02-22LibWeb: Make factory method of Fetch::Response fallibleKenneth Myhra
2023-02-22LibWeb: Make factory method of Fetch::Request fallibleKenneth Myhra
2023-02-22LibWeb: Make factory method of Fetch::HeadersIterator fallibleKenneth Myhra
2023-02-19LibWeb: Use is_ascii_case_insensitive_match() where the spec says toSam Atkins
2023-02-18LibWeb: Make factory method of FileAPI::Blob fallibleKenneth Myhra
2023-02-17LibJS+Everywhere: Convert JS::Error to StringTimothy Flynn
This includes an Error::create overload to create an Error from a UTF-8 StringView. If creating a String from that view fails, the factory will return an OOM InternalError instead. VM::throw_completion can also make use of this overload via its perfect forwarding.
2023-02-13LibWeb: Clarify WebIDL::Promise as an alias for JS::PromiseCapabilitynetworkException
This patch adds the WebIDL::Promise type explicitly defined in the WebIDL spec to be a PromiseCapability Record from ecma262.
2023-02-11LibWeb: Implement Headers.getSetCookie()Linus Groh
This is a normative change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/e4d3480 This also implements the changes to the 'sort and combine' algorithm, which now treats "set-cookie" headers differently, and is exposed to JS via the Headers' iterator. Passes all 21 WPT tests :^) http://wpt.live/fetch/api/headers/header-setcookie.any.html
2023-02-11LibWeb: Fix UAF in convert_header_names_to_a_sorted_lowercase_set()Linus Groh
We can't keep a span (ReadonlyBytes) to a move()'d ByteBuffer in the header_names_seen HashTable - copy the original name span instead which works the same thanks to CaseInsensitiveBytesTraits. This would sporadically fail the contains() check due to garbage data, later leading to a VERIFY() crash in the OrderedHashTable append loop.
2023-02-10LibWeb/Fetch: Implement CORS preflightLuke Wilde
The main things missing is the CORS preflight cache and making extract_header_list_values properly parse, validate and return split values for the Access-Control headers.
2023-02-10LibWeb: Make extract_header_list_values differentiate parsing failuresLuke Wilde
Previously, parsing failures and the header not existing made extract_header_list_values return an empty Optional, making it impossible to differentiate between the two. Required for implementing CORS-preflight, where parsing failures for the headers makes it fail, but not having them doesn't make it fail in all cases.
2023-02-10LibWeb/Fetch: Don't add cookies when creating ResourceLoader requestLuke Wilde
Using LoadRequest::create_for_url_on_page will unconditionally add cookies as long as there's a page available. However, it is up to http_network_or_cache_fetch to determine if cookies should be added to the request. This was noticed when implementing CORS-preflight requests, where we sent cookies in OPTIONS requests.
2023-02-10LibWeb: Add missing GCPtr.h includes to Fetch headersTimothy Flynn
These are missing in most Fetch headers, and clangd is (rightfully) very loud about it on a few of these.
2023-02-10AK+Everywhere: Do not implicitly copy variables in TRY macrosTimothy Flynn
For example, consider cases where we want to propagate errors only in specific instances: auto result = read_data(); // something like ErrorOr<ByteBuffer> if (result.is_error() && result.error().code() != EINTR) continue; auto bytes = TRY(result); The TRY invocation will currently copy the byte buffer when the expression (in this case, just a local variable) is stored into _temporary_result. This patch binds the expression to a reference to prevent such copies. In less trival invocations (such as TRY(some_function()), this will incur only temporary lifetime extensions, i.e. no functional change.
2023-02-09LibJS+LibWeb: Convert string view PrimitiveString instances to StringTimothy Flynn
First, this adds an overload of PrimitiveString::create for StringView. This overload will throw an OOM completion if creating a String fails. This is not only a bit more convenient, but it also ensures at compile time that all PrimitiveString::create(string_view) invocations will be handled as String and OOM-aware. Next, this wraps all invocations to PrimitiveString::create(string_view) with MUST_OR_THROW_OOM. A small PrimitiveString::create(DeprecatedFlyString) overload also had to be added to disambiguate between the StringView and DeprecatedString overloads.
2023-01-29LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocateTimothy Flynn
Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
2023-01-29LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errorsTimothy Flynn
Note that as of this commit, there aren't any such throwers, and the call site in Heap::allocate will drop exceptions on the floor. This commit only serves to change the declaration of the overrides, make sure they return an empty value, and to propagate OOM errors frm their base initialize invocations.
2023-01-27AK: Remove StringBuilder::build() in favor of to_deprecated_string()Linus Groh
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
2023-01-22LibJS+LibWeb: Convert empty PrimitiveString invocators to StringTimothy Flynn
2023-01-15LibWeb: Make sure that fetch() response cookies get savedAndreas Kling
We have to provide the Web::Page* in order for cookies to get saved.
2023-01-15Everywhere: Fully qualify IsLvalueReference in TRY() macrosAndrew Kaster
If USING_AK_GLOBALLY is not defined, the name IsLvalueReference might not be available in the global namespace. Follow the pattern established in LibTest to fully qualify AK types in macros to avoid this problem.
2023-01-13AK+Everywhere: Disallow returning a reference from a fallible expressionTimothy Flynn
This will silently make a copy. Rather than masking this behavior, let's explicitly disallow it.
2023-01-10LibWeb: Move setting of Web object prototypes to initialize()Timothy Flynn
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
2023-01-10LibWeb: Generate dedicated methods to create Web constructors/prototypesTimothy Flynn
Currently, for each exposed interface, we generate one massive function to create every Web constructor and prototype. In an effort to lazily create these instead, this first step is to extract the creation of each of these into its own method. First, this generates a forwarding header for all IDL types. This is to allow callers to remain unchanged without forcing them to include the (very heavy) generated IDL headers. This header is included by LibWeb's forwarding header. Next, this defines a base template method on Web::Bindings::Intrinsics to create a prototype/constructor pair. Specializations of this template are now generated in a new .cpp file, IntrinsicDefinitions.cpp. The base Intrinsics class is updated to use this new method, and will continue to cache the result. Last, some WebAssembly classes are updated to use this new mechanism. They were using some ad hoc cache keys that are now in line with the generated specializations. That one massive function is still used to invoke these specializations, so they are not lazy as of this commit.
2023-01-08LibJS+Everywhere: Make PrimitiveString and Utf16String fallibleTimothy Flynn
This makes construction of Utf16String fallible in OOM conditions. The immediate impact is that PrimitiveString must then be fallible as well, as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string from ropes. There are a couple of places where it is very non-trivial to propagate the error further. A FIXME has been added to those locations.
2023-01-08LibJS+LibWeb: Move the macro to convert ENOMEM to an exception to LibJSTimothy Flynn
Move the macro to LibJS and change it to return a throw completion instead of a WebIDL exception. This will let us use this macro within LibJS to handle OOM conditions.
2022-12-20AK: Stop using `DeprecatedString` in Base64 encodingJelle Raaijmakers
2022-12-15LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtrLinus Groh
2022-12-15LibJS: Add make_handle({Nonnull,}GCPtr<T>) overloadsLinus Groh
2022-12-14LibJS: Convert Array::create{,_from}() to NonnullGCPtrLinus Groh
2022-12-08LibWeb/Fetch: Remove redundant timingInfo variablesLinus Groh
This is an editorial change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/e8b67b0
2022-12-08LibWeb/Fetch: Share validation logic in the Headers classLinus Groh
This is an editorial change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/f435978
2022-12-08LibWeb/Fetch: Remove Authorization header upon cross-origin redirectLinus Groh
This is a change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/9004f4e
2022-12-08LibWeb/Fetch: Tweak wording in some spec commentsLinus Groh
This is a change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/223ca89
2022-12-08LibWeb/Fetch: Update spec comment to decode bytes to stringLinus Groh
This is a change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/a04d096
2022-12-08LibWeb/Fetch: Refactor forbidden request-headersLinus Groh
This is a change in the Fetch spec. See: - https://github.com/whatwg/fetch/commit/92e6c91 - https://github.com/whatwg/xhr/commit/494431a
2022-12-08LibWeb/Fetch: Use tuple syntax for headers in spec commentsLinus Groh
This is an editorial change in the Fetch spec. See: https://github.com/whatwg/fetch/commit/b482186
2022-12-07LibJS: Replace standalone js_string() with PrimitiveString::create()Linus Groh
Note that js_rope_string() has been folded into this, the old name was misleading - it would not always create a rope string, only if both sides are not empty strings. Use a three-argument create() overload instead.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)