feat(http): add support for blob as a response type (#10190)
This commit is contained in:
committed by
Victor Berchet
parent
db54a84d14
commit
76b8a49bfb
@@ -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.
|
||||
|
||||
@@ -67,7 +67,8 @@ export enum ContentType {
|
||||
* @experimental
|
||||
*/
|
||||
export enum ResponseContentType {
|
||||
ArrayBuffer,
|
||||
Text,
|
||||
Json,
|
||||
Text
|
||||
ArrayBuffer,
|
||||
Blob
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user