feat(http): add support for blob as a response type (#10190)

This commit is contained in:
Damien Cassan
2016-07-21 22:44:38 +02:00
committed by Victor Berchet
parent db54a84d14
commit 76b8a49bfb
6 changed files with 36 additions and 11 deletions
@@ -120,6 +120,9 @@ export class XHRConnection implements Connection {
case ResponseContentType.Text:
_xhr.responseType = 'text';
break;
case ResponseContentType.Blob:
_xhr.responseType = 'blob';
break;
default:
throw new Error('The selected responseType is not supported');
}
@@ -46,9 +46,9 @@ import {ResponseOptionsArgs} from './interfaces';
export class ResponseOptions {
// TODO: FormData | Blob
/**
* String, Object, ArrayBuffer representing the body of the {@link Response}.
* String, Object, ArrayBuffer or Blob representing the body of the {@link Response}.
*/
body: string|Object|ArrayBuffer;
body: string|Object|ArrayBuffer|Blob;
/**
* Http {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html status code}
* associated with the response.
+3 -2
View File
@@ -67,7 +67,8 @@ export enum ContentType {
* @experimental
*/
export enum ResponseContentType {
ArrayBuffer,
Text,
Json,
Text
ArrayBuffer,
Blob
}
+1 -2
View File
@@ -67,8 +67,7 @@ export interface RequestArgs extends RequestOptionsArgs { url: string; }
* @experimental
*/
export type ResponseOptionsArgs = {
// TODO: Support Blob, JSON
body?: string | Object | FormData | ArrayBuffer; status?: number; statusText?: string;
body?: string | Object | FormData | ArrayBuffer | Blob; status?: number; statusText?: string;
headers?: Headers;
type?: ResponseType;
url?: string;