feat(http): add support for ArrayBuffer

Add the buffer option to store response in ArrayBuffer
Improve the interface to get back response independently of the buffer type
This commit is contained in:
Damien Cassan
2016-02-24 16:37:18 +01:00
committed by Jeff Cross
parent 0ccb6e0dfc
commit 1266460386
12 changed files with 218 additions and 29 deletions

View File

@ -8,7 +8,7 @@
import {StringWrapper, isPresent} from '../src/facade/lang';
import {ContentType, RequestMethod} from './enums';
import {ContentType, RequestMethod, ResponseBuffer} from './enums';
import {Headers} from './headers';
import {normalizeMethodName} from './http_utils';
import {RequestArgs} from './interfaces';
@ -72,6 +72,8 @@ export class Request {
private contentType: ContentType;
/** Enable use credentials */
withCredentials: boolean;
/* Select a buffer to store the response */
buffer: ResponseBuffer;
constructor(requestOptions: RequestArgs) {
// TODO: assert that url is present
let url = requestOptions.url;
@ -95,6 +97,7 @@ export class Request {
// TODO(jeffbcross): implement behavior
this.headers = new Headers(requestOptions.headers);
this.withCredentials = requestOptions.withCredentials;
this.buffer = requestOptions.buffer;
}