Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/webapi/xml_http_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ impl XmlHttpRequest {
}
}

/// Returns the string containing the text of all the request headers.
/// The headers are separated separated by CRLF.
///
/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders)
// https://xhr.spec.whatwg.org/#ref-for-dom-xmlhttprequest-getallresponseheaders
pub fn get_all_response_headers(&self) -> Option<String> {
let headers = js!( return @{self}.getAllResponseHeaders(); );
match headers {
Value::Null => None,
Value::String(text) => Some(text),
_ => unreachable!(),
}
}

/// Sets the value of an HTTP request header. Must be called after `open()`,
/// but before `send()`. If this method is called several times with the same
/// header, the values are merged into one single request header.
Expand Down