Added Headers constructor options to whatwg-fetch (#10313)

This commit is contained in:
Nikita Kobzev
2016-07-28 17:28:41 +03:00
committed by Masahiro Wakame
parent 73291dad15
commit d997f92b89
2 changed files with 19 additions and 0 deletions

View File

@@ -1,5 +1,18 @@
/// <reference path="whatwg-fetch.d.ts" />
function test_HeadersCopiedFromHeaders() {
var source = new Headers();
source.append('Content-Type', 'application/json');
return new Headers(source);
}
function test_HeadersCopiedFromHash() {
var source:HeadersMap = {
'Content-Type': 'application/json'
};
return new Headers(source);
}
function test_fetchUrlWithOptions() {
var headers = new Headers();
headers.append("Content-Type", "application/json");

View File

@@ -41,7 +41,12 @@ type RequestCache =
"default" | "no-store" | "reload" | "no-cache" |
"force-cache" | "only-if-cached";
declare interface HeadersMap {
[index: string]: string;
}
declare class Headers {
constructor(headers?:Headers|HeadersMap)
append(name: string, value: string): void;
delete(name: string):void;
get(name: string): string;
@@ -60,6 +65,7 @@ declare class Body {
json<T>(): Promise<T>;
text(): Promise<string>;
}
declare class Response extends Body {
constructor(body?: BodyInit, init?: ResponseInit);
static error(): Response;