diff options
author | ztplz <mysticzt@gmail.com> | 2018-10-20 00:12:36 +0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-19 12:12:36 -0400 |
commit | 7210e7b33b84382d4f418ab1be37fea85c2e1422 (patch) | |
tree | f7dcb6d486d3b451fc12c3357ff2e48e4dde3ab0 /js/fetch.ts | |
parent | 198fa31ec150b069dca39b94b2049d3ff65213e9 (diff) |
Make fetch header compliant with the current spec (#1019)
Diffstat (limited to 'js/fetch.ts')
-rw-r--r-- | js/fetch.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/js/fetch.ts b/js/fetch.ts index ae62c576d..eef149e4d 100644 --- a/js/fetch.ts +++ b/js/fetch.ts @@ -5,7 +5,8 @@ import { createResolvable, Resolvable, typedArrayToArrayBuffer, - notImplemented + notImplemented, + CreateIterableIterator } from "./util"; import * as flatbuffers from "./flatbuffers"; import { sendAsync } from "./dispatch"; @@ -70,6 +71,11 @@ export class DenoHeaders implements domTypes.Headers { this.headerMap.delete(newname); } + entries(): IterableIterator<[string, string]> { + const iterators = this.headerMap.entries(); + return new CreateIterableIterator(iterators); + } + get(name: string): string | null { const [newname] = this.normalizeParams(name); const value = this.headerMap.get(newname); @@ -81,11 +87,21 @@ export class DenoHeaders implements domTypes.Headers { return this.headerMap.has(newname); } + keys(): IterableIterator<string> { + const iterators = this.headerMap.keys(); + return new CreateIterableIterator(iterators); + } + set(name: string, value: string): void { const [newname, newvalue] = this.normalizeParams(name, value); this.headerMap.set(newname, newvalue); } + values(): IterableIterator<string> { + const iterators = this.headerMap.values(); + return new CreateIterableIterator(iterators); + } + forEach( callbackfn: (value: string, key: string, parent: domTypes.Headers) => void, // tslint:disable-next-line:no-any @@ -95,6 +111,10 @@ export class DenoHeaders implements domTypes.Headers { callbackfn(value, name, this); }); } + + [Symbol.iterator](): IterableIterator<[string, string]> { + return this.entries(); + } } class FetchResponse implements domTypes.Response { |