Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XmlHttpRequest add get_all_response_headers method #381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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