Skip to content

Commit

Permalink
Fetch: Response's trailer
Browse files Browse the repository at this point in the history
See whatwg/fetch#473 for context.
  • Loading branch information
annevk committed Feb 13, 2017
1 parent b4ba266 commit 763c1f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions fetch/api/response/response-idl.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
readonly attribute boolean ok;
readonly attribute ByteString statusText;
[SameObject] readonly attribute Headers headers;
readonly attribute Promise<Headers> trailer;

[NewObject] Response clone();
};
Expand Down
24 changes: 24 additions & 0 deletions fetch/api/response/response-trailer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<title>trailer() test</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<!-- based on /XMLHttpRequest/getresponseheader-chunked-trailer.htm -->
<script>
promise_test(() => {
return fetch("/XMLHttpRequest/resources/chunked.py").then(res => {
assert_equals(res.headers.get("Trailer"), "X-Test-Me")
assert_equals(res.headers.get("X-Test-Me"), null)
assert_equals(res.headers.get("Content-Type"), "text/plain")
return Promise.all([
res.text().then(text => {
assert_equals(text, "First chunk\r\nSecond chunk\r\nYet another (third) chunk\r\nYet another (fourth) chunk\r\n")
}),
res.trailer.then(trailers => {
assert_equals(trailers.get("X-Test-Me"), "Trailer header value")
assert_throws(new TypeError, trailers.append("Immutable-My-Ass", "Hi!"))
})
])
})
})
</script>

0 comments on commit 763c1f5

Please sign in to comment.