summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
AgeCommit message (Collapse)Author
2023-04-15AK+Everywhere: Change URL::path() to serialize_path()MacDue
This now defaults to serializing the path with percent decoded segments (which is what all callers expect), but has an option not to. This fixes `file://` URLs with spaces in their paths. The name has been changed to serialize_path() path to make it more clear that this method will generate a new string each call (except for the cannot_be_a_base_url() case). A few callers have then been updated to avoid repeatedly calling this function.
2023-04-04LibWeb: Do not use OS error codes in the error callback for file:// URLsTimothy Flynn
The error code passed here is expected to be an HTTP error code. Passing errno codes does not make sense in that context.
2023-03-22LibWeb: Make ResourceLoader insert a Content-Type header for file://Andreas Kling
We make a guess using the MIME type guessing API in LibCore. This frees clients of this code from having to do the guessing.
2023-03-15LibWeb: Don't treat erroring subresource loads as successAndreas Kling
If a subresource fails to load, we don't care that we got some custom 404 page. The subresource should still be considered failed. This is an ad-hoc solution that unbreaks Acid2. This code will eventually be replaced by fetch mechanisms.
2023-02-24LibWeb: Render HTML content if present for HTTP error pagesAndreas Kling
If an HTTP response fails with an error code (e.g 403) but still has body content, we now render the content. We only fall back to our own built-in error page if there's no body.
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-02-10Everywhere: Remove needless copies of Error / ErrorOr instancesTimothy Flynn
Either take the underlying objects with release_* methods or move() the instances around.
2023-02-01LibWeb+WebContent: Do not reference-count file request objectsTimothy Flynn
There is currently a memory leak with these file request objects due to the callback on_file_request_finish referencing itself in its capture list. This object does not need to be reference counted or allocated on the heap. It is only ever stored in a HashMap until a response is received from the browser, and it is not shared.
2022-12-30LibWeb: Store cookies for every HTTP responseLuke Wilde
As per Fetch, we are supposed to store cookies from Set-Cookie as soon as we receive response headers for any HTTP response, even in error cases. Required by Twitter to login, as it sets cookies via XHR.
2022-12-12LibCore: Rename `Stream::read_all` to `read_until_eof`Tim Schumacher
This generally seems like a better name, especially if we somehow also need a better name for "read the entire buffer, but not the entire file" somewhere down the line.
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 :^)
2022-11-19Everywhere: Remove unnecessary mutable attributes from lambdasMacDue
These lambdas were marked mutable as they captured a Ptr wrapper class by value, which then only returned const-qualified references to the value they point from the previous const pointer operators. Nothing is actually mutating in the lambdas state here, and now that the Ptr operators don't add extra const qualifiers these can be removed.
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-10-05LibWeb: Pass status code to ResourceLoader error callback when availableLinus Groh
2022-09-29AK+Everywhere: Replace "protocol" with "scheme" url helpersnetworkException
URL had properly named replacements for protocol(), set_protocol() and create_with_file_protocol() already. This patch removes these function and updates all call sites to use the functions named according to the specification. See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-07LibWeb+WebContent: Add abstraction layer for event loop and timersAndreas Kling
Instead of using Core::EventLoop and Core::Timer directly, LibWeb now goes through a Web::Platform abstraction layer instead. This will allow us to plug in Qt's event loop (and QTimer) over in Ladybird, to avoid having to deal with multiple event loops.
2022-07-17LibWeb: Paper over a VERIFY() crash in ResourceLoader for nowAndreas Kling
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-03LibWeb: Add timeout_callback to ResourceLoader::load()Kenneth Myhra
2022-07-03LibWeb: Use a single shot timer instead of an ordinary repetitive timerKenneth Myhra
2022-06-27Browser+LibWeb+WebContent: Allow Browser to load local filesLucas CHOLLET
To achieve this goal: - The Browser unveils "/tmp/portal/filesystemaccess" - Pass the page through LoadRequest => ResourceLoader - ResourceLoader requests a file to the FileSystemAccessServer via IPC - OutOfProcessWebView handles it and sends a file descriptor back to the Page.
2022-06-23LibWeb: Fix unsafe capture of ref-to-local when setting up load timeoutAndreas Kling
We were capturing a reference to a stack local and then persisting the closure, causing it to dereference a long-gone object when invoked.
2022-06-21LibWeb: Add timeout functionality to ResourceLoaderKenneth Myhra
Add timeout functionality to ResourceLoader and use it from XMLHttpRequest.
2022-06-10LibWeb: Apply content filter to DNS prefetch and pre-connectLuke Wilde
Performing DNS prefetch or pre-connect on filtered URLs is wasteful, as we would block any actual use further down the line. A bunch of websites perform DNS prefetch and/or pre-connect to trackers as well, for example: ``` prefetch DNS for 'https://adserver-us.adtech.advertising.com/' prefetch DNS for 'https://secure.adnxs.com/' prefetch DNS for 'https://bidder.criteo.com/' prefetch DNS for 'https://static.criteo.net/' prefetch DNS for 'https://cdn.krxd.net/' prefetch DNS for 'https://widgets.outbrain.com/' prefetch DNS for 'https://images.outbrain.com/' prefetch DNS for 'https://log.outbrain.com/ prefetch DNS for 'https://amplifypixel.outbrain.com/' prefetch DNS for 'https://odb.outbrain.com/' prefetch DNS for 'https://js-sec.indexww.com/' prefetch DNS for 'https://as-sec.casalemedia.com/' prefetch DNS for 'https://as.casalemedia.com/' prefetch DNS for 'https://sofia.trustx.org/' prefetch DNS for 'https://c.amazon-adsystem.com/' prefetch DNS for 'https://s.amazon-adsystem.com/' prefetch DNS for 'https://aax.amazon-adsystem.com/' prefetch DNS for 'https://t.teads.tv/' prefetch DNS for 'https://beacon.krxd.net/' pre-connect to 'https://www.google-analytics.com/' pre-connect to 'https://www.googletagmanager.com/' ```
2022-05-21LibHTTP+LibWeb: Accept Brotli encoded responsesMichiel Visser
2022-05-15LibWeb: Abstract the LibProtocol ResourceLoader connectionDexesTTP
This is the final component that required LibProtocol as a dependency of LibWeb. With this, we can now remove the dependency, and LibWeb no longer requires IPC to work :^)
2022-05-13LibWeb: Make about:blank load correctlySam Atkins
- Don't treat an empty `about:blank` resource as an error. - Give `about:` urls a content-type so `FrameLoader::parse_document()` won't reject them.
2022-05-06LibWeb: Only generate ResourceLoader signposts while on SerenityDexesTTP
2022-04-10LibWeb: Remove unused ResourceLoader::load_sync()Andreas Kling
There are no remaining users of this API, everyone has been migrated to asynchronous resource loading.
2022-04-09LibWeb: Remove debug spam about proxy configuration lookupsAndreas Kling
2022-04-09Browser+LibWeb+WebContent: Implement per-URL-pattern proxiesAli Mohammad Pur
...at least for SOCKS5.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-24LibWeb: Emit signposts for resource loadsSimon Wanner
2022-03-23LibWeb: Evict replaced Resource objects from cacheTimothy Flynn
When a Resource is converted to an ImageResource, evict the original resource from cache. The original resource's data has been moved, so on a warm reload of a page, when that resource is loaded from cache, it would not have any data to actually show.
2022-03-09LibWeb: Fail resource loads on HTTP 4xx or 5xx errorAndreas Kling
This fixes an issue on ACID3 where failing image loads with body content would still get displayed.
2022-02-04LibWeb: Make debug logging of resource load errors red instead of greenAndreas Kling
Red is a bit more suspicious than green, after all. :^)
2022-01-24AK+Userland: Make AK::decode_base64 return ErrorOrSam Atkins
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2021-11-08LibCore: Use ErrorOr<T> for Core::File::open()Andreas Kling
2021-10-23AK+Everywhere: Make Base64 decoding fallibleBen Wiederhake
2021-09-28LibWeb: Implement the dns-prefetch and preconnect link relationshipsAli Mohammad Pur
2021-09-22LibWeb: Log resource load success before invoking success callbackAndreas Kling
The success callback may trigger JavaScript execution, causing resource load times to appear much longer than they actually are. :^)
2021-09-19LibWeb: Avoid introducing a reference cycle in ResourceLoader::load()Ali Mohammad Pur
Previously we were kinda sorta resolving the reference cycle, but let's just keep the requests in a hashtable instead of relying on hard to track refcount tricks. Fixes #7314.
2021-09-16LibWeb: Don't dump full data URLs in ResourceLoader loggingAndreas Kling
Some pages use *really* large data URLs. :^)
2021-09-14AK: Make URL::m_port an Optional<u16>, Expose raw port getterIdan Horowitz
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
2021-09-13LibWeb: Add the Web::URL namespace and move URLEncoder to itIdan Horowitz
This namespace will be used for all interfaces defined in the URL specification, like URL and URLSearchParams. This has the unfortunate side-effect of requiring us to use the fully qualified AK::URL name whenever we want to refer to the AK class, so this commit also fixes all such references.
2021-09-12LibWeb: Log resource loading success, failure, and durationBrian Gianforcaro
When debugging why your website isn't loading in LibWeb the resource loader is a blind spot as we don't have much logging except on certain error paths. This can lead to confusing situations where the browser just appears to hang. This changes attempts to fix that by adding common success and failure logging handlers so all resource loading outcomes can are logged.
2021-09-12LibWeb: Start tracking elapsed time when a resource is loadedBrian Gianforcaro