1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibWeb: Implement XMLHttpRequest.getAllResponseHeaders()

This commit is contained in:
Andreas Kling 2021-09-19 22:32:33 +02:00
parent 95559c4277
commit 7ef4d75716
3 changed files with 21 additions and 0 deletions

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/QuickSort.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibWeb/Bindings/EventWrapper.h>
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
@ -271,4 +272,22 @@ void XMLHttpRequest::set_onreadystatechange(HTML::EventHandler value)
set_event_handler_attribute(Web::XHR::EventNames::readystatechange, move(value));
}
// https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method
String XMLHttpRequest::get_all_response_headers() const
{
// FIXME: Implement the spec-compliant sort order.
StringBuilder builder;
auto keys = m_response_headers.keys();
quick_sort(keys);
for (auto& key : keys) {
builder.append(key);
builder.append(": ");
builder.append(m_response_headers.get(key).value());
builder.append("\r\n");
}
return builder.to_string();
}
}