diff options
author | Linus Groh <mail@linusgroh.de> | 2022-10-24 18:51:25 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-24 22:58:37 +0100 |
commit | 7e7def71c19a526533c34d8da4cf4394a7a2004d (patch) | |
tree | a4c204e170418f9e57b06addd6d852e3d87e6ef9 | |
parent | 8f8fcfee1a812d9b669ac962cda6e69e54821981 (diff) | |
download | serenity-7e7def71c19a526533c34d8da4cf4394a7a2004d.zip |
LibWeb: Use getters instead of direct member access in Response methods
This fixes the behavior of those methods for FilteredResponse subclasses
as those only override the getter methods, not their private members.
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index d523e35f69..398f7fed19 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -44,23 +44,26 @@ NonnullRefPtr<Response> Response::network_error() bool Response::is_aborted_network_error() const { // A response whose type is "error" and aborted flag is set is known as an aborted network error. - return m_type == Type::Error && m_aborted; + // NOTE: We have to use the virtual getter here to not bypass filtered responses. + return type() == Type::Error && aborted(); } // https://fetch.spec.whatwg.org/#concept-network-error bool Response::is_network_error() const { // A response whose type is "error" is known as a network error. - return m_type == Type::Error; + // NOTE: We have to use the virtual getter here to not bypass filtered responses. + return type() == Type::Error; } // https://fetch.spec.whatwg.org/#concept-response-url Optional<AK::URL const&> Response::url() const { // A response has an associated URL. It is a pointer to the last URL in responseās URL list and null if responseās URL list is empty. - if (m_url_list.is_empty()) + // NOTE: We have to use the virtual getter here to not bypass filtered responses. + if (url_list().is_empty()) return {}; - return m_url_list.last(); + return url_list().last(); } // https://fetch.spec.whatwg.org/#concept-response-location-url @@ -69,7 +72,8 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& reques // The location URL of a response response, given null or an ASCII string requestFragment, is the value returned by the following steps. They return null, failure, or a URL. // 1. If responseās status is not a redirect status, then return null. - if (!is_redirect_status(m_status)) + // NOTE: We have to use the virtual getter here to not bypass filtered responses. + if (!is_redirect_status(status())) return Optional<AK::URL> {}; // FIXME: 2. Let location be the result of extracting header list values given `Location` and responseās header list. |