mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibWeb: Implement XMLHttpRequest.getResponseHeader()
This lets jQuery's AJAX functionality progress further :^)
This commit is contained in:
parent
288b90a297
commit
57ead17d54
Notes:
sideshowbarker
2024-07-18 20:51:50 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/57ead17d54b Pull-request: https://github.com/SerenityOS/serenity/pull/6090
4 changed files with 8 additions and 2 deletions
|
@ -102,7 +102,7 @@ static size_t get_function_length(FunctionType& function)
|
|||
struct Type {
|
||||
String name;
|
||||
bool nullable { false };
|
||||
bool is_string() const { return name.is_one_of("DOMString", "USVString", "CSSOMString"); }
|
||||
bool is_string() const { return name.is_one_of("ByteString", "CSSOMString", "DOMString", "USVString"); }
|
||||
};
|
||||
|
||||
struct Parameter {
|
||||
|
|
|
@ -229,7 +229,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send()
|
|||
// we need to make ResourceLoader give us more detailed updates than just "done" and "error".
|
||||
ResourceLoader::the().load(
|
||||
request,
|
||||
[weak_this = make_weak_ptr()](auto data, auto&, auto status_code) {
|
||||
[weak_this = make_weak_ptr()](auto data, auto& response_headers, auto status_code) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
auto& xhr = const_cast<XMLHttpRequest&>(*weak_this);
|
||||
|
@ -245,6 +245,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send()
|
|||
|
||||
xhr.m_ready_state = ReadyState::Done;
|
||||
xhr.m_status = status_code.value_or(0);
|
||||
xhr.m_response_headers = move(response_headers);
|
||||
xhr.m_send = false;
|
||||
xhr.dispatch_event(DOM::Event::create(EventNames::readystatechange));
|
||||
xhr.fire_progress_event(EventNames::load, transmitted, length);
|
||||
|
|
|
@ -76,6 +76,8 @@ public:
|
|||
|
||||
DOM::ExceptionOr<void> set_request_header(const String& header, const String& value);
|
||||
|
||||
String get_response_header(const String& name) { return m_response_headers.get(name).value_or({}); }
|
||||
|
||||
private:
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
|
@ -98,6 +100,7 @@ private:
|
|||
URL m_url;
|
||||
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_request_headers;
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
|
||||
|
||||
bool m_synchronous { false };
|
||||
bool m_upload_complete { false };
|
||||
|
|
|
@ -16,4 +16,6 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
undefined setRequestHeader(DOMString name, DOMString value);
|
||||
undefined send();
|
||||
|
||||
ByteString? getResponseHeader(ByteString name);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue