revert(format): Revert "chore(format): update to latest formatter"
This reverts commit 03627aa84d
.
This commit is contained in:
@ -45,8 +45,8 @@ export class JSONPConnection_ extends JSONPConnection {
|
||||
private _responseData: any;
|
||||
private _finished: boolean = false;
|
||||
|
||||
constructor(
|
||||
req: Request, private _dom: BrowserJsonp, private baseResponseOptions?: ResponseOptions) {
|
||||
constructor(req: Request, private _dom: BrowserJsonp,
|
||||
private baseResponseOptions?: ResponseOptions) {
|
||||
super();
|
||||
if (req.method !== RequestMethod.Get) {
|
||||
throw makeTypeError(JSONP_ERR_WRONG_METHOD);
|
||||
|
@ -177,8 +177,8 @@ export class MockBackend implements ConnectionBackend {
|
||||
constructor() {
|
||||
this.connectionsArray = [];
|
||||
this.connections = new Subject();
|
||||
this.connections.subscribe(
|
||||
(connection: MockConnection) => this.connectionsArray.push(connection));
|
||||
this.connections.subscribe((connection: MockConnection) =>
|
||||
this.connectionsArray.push(connection));
|
||||
this.pendingConnections = new Subject();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ export class RequestOptions {
|
||||
* Http method with which to execute a {@link Request}.
|
||||
* Acceptable methods are defined in the {@link RequestMethod} enum.
|
||||
*/
|
||||
method: RequestMethod|string;
|
||||
method: RequestMethod | string;
|
||||
/**
|
||||
* {@link Headers} to be attached to a {@link Request}.
|
||||
*/
|
||||
@ -58,9 +58,9 @@ export class RequestOptions {
|
||||
this.headers = isPresent(headers) ? headers : null;
|
||||
this.body = isPresent(body) ? body : null;
|
||||
this.url = isPresent(url) ? url : null;
|
||||
this.search = isPresent(search) ?
|
||||
(isString(search) ? new URLSearchParams(<string>(search)) : <URLSearchParams>(search)) :
|
||||
null;
|
||||
this.search = isPresent(search) ? (isString(search) ? new URLSearchParams(<string>(search)) :
|
||||
<URLSearchParams>(search)) :
|
||||
null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,9 +95,9 @@ export class RequestOptions {
|
||||
body: isPresent(options) && isPresent(options.body) ? options.body : this.body,
|
||||
url: isPresent(options) && isPresent(options.url) ? options.url : this.url,
|
||||
search: isPresent(options) && isPresent(options.search) ?
|
||||
(isString(options.search) ? new URLSearchParams(<string>(options.search)) :
|
||||
(<URLSearchParams>(options.search)).clone()) :
|
||||
this.search
|
||||
(isString(options.search) ? new URLSearchParams(<string>(options.search)) :
|
||||
(<URLSearchParams>(options.search)).clone()) :
|
||||
this.search
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class ResponseOptions {
|
||||
/**
|
||||
* String or Object representing the body of the {@link Response}.
|
||||
*/
|
||||
body: string|Object;
|
||||
body: string | Object;
|
||||
/**
|
||||
* Http {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html status code}
|
||||
* associated with the response.
|
||||
|
@ -1,6 +1,20 @@
|
||||
import {isPresent, isBlank, isJsObject, isType, StringWrapper, Json} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
isPresent,
|
||||
isBlank,
|
||||
isJsObject,
|
||||
isType,
|
||||
StringWrapper,
|
||||
Json
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
||||
import {isListLikeIterable, iterateListLike, Map, MapWrapper, StringMapWrapper, ListWrapper,} from 'angular2/src/facade/collection';
|
||||
import {
|
||||
isListLikeIterable,
|
||||
iterateListLike,
|
||||
Map,
|
||||
MapWrapper,
|
||||
StringMapWrapper,
|
||||
ListWrapper,
|
||||
} from 'angular2/src/facade/collection';
|
||||
|
||||
/**
|
||||
* Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
|
||||
@ -31,7 +45,7 @@ import {isListLikeIterable, iterateListLike, Map, MapWrapper, StringMapWrapper,
|
||||
export class Headers {
|
||||
/** @internal */
|
||||
_headersMap: Map<string, string[]>;
|
||||
constructor(headers?: Headers|{[key: string]: any}) {
|
||||
constructor(headers?: Headers | {[key: string]: any}) {
|
||||
if (headers instanceof Headers) {
|
||||
this._headersMap = (<Headers>headers)._headersMap;
|
||||
return;
|
||||
@ -97,7 +111,7 @@ export class Headers {
|
||||
/**
|
||||
* Sets or overrides header value for given name.
|
||||
*/
|
||||
set(header: string, value: string|string[]): void {
|
||||
set(header: string, value: string | string[]): void {
|
||||
var list: string[] = [];
|
||||
|
||||
if (isListLikeIterable(value)) {
|
||||
|
@ -12,9 +12,8 @@ function httpRequest(backend: ConnectionBackend, request: Request): Observable<R
|
||||
return backend.createConnection(request).response;
|
||||
}
|
||||
|
||||
function mergeOptions(
|
||||
defaultOpts: BaseRequestOptions, providedOpts: RequestOptionsArgs, method: RequestMethod,
|
||||
url: string): RequestOptions {
|
||||
function mergeOptions(defaultOpts: BaseRequestOptions, providedOpts: RequestOptionsArgs,
|
||||
method: RequestMethod, url: string): RequestOptions {
|
||||
var newOptions = defaultOpts;
|
||||
if (isPresent(providedOpts)) {
|
||||
// Hack so Dart can used named parameters
|
||||
@ -101,7 +100,7 @@ export class Http {
|
||||
* object can be provided as the 2nd argument. The options object will be merged with the values
|
||||
* of {@link BaseRequestOptions} before performing the request.
|
||||
*/
|
||||
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
|
||||
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
|
||||
var responseObservable: any;
|
||||
if (isString(url)) {
|
||||
responseObservable = httpRequest(
|
||||
@ -119,9 +118,8 @@ export class Http {
|
||||
* Performs a request with `get` http method.
|
||||
*/
|
||||
get(url: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
|
||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||
RequestMethod.Get, url)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,9 +127,9 @@ export class Http {
|
||||
*/
|
||||
post(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend, new Request(mergeOptions(
|
||||
this._defaultOptions.merge(new RequestOptions({body: body})), options,
|
||||
RequestMethod.Post, url)));
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||
options, RequestMethod.Post, url)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,18 +137,17 @@ export class Http {
|
||||
*/
|
||||
put(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend, new Request(mergeOptions(
|
||||
this._defaultOptions.merge(new RequestOptions({body: body})), options,
|
||||
RequestMethod.Put, url)));
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||
options, RequestMethod.Put, url)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a request with `delete` http method.
|
||||
*/
|
||||
delete (url: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));
|
||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||
RequestMethod.Delete, url)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,18 +155,17 @@ export class Http {
|
||||
*/
|
||||
patch(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend, new Request(mergeOptions(
|
||||
this._defaultOptions.merge(new RequestOptions({body: body})), options,
|
||||
RequestMethod.Patch, url)));
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||
options, RequestMethod.Patch, url)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a request with `head` http method.
|
||||
*/
|
||||
head(url: string, options?: RequestOptionsArgs): Observable<Response> {
|
||||
return httpRequest(
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
|
||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||
RequestMethod.Head, url)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +181,7 @@ export class Jsonp extends Http {
|
||||
* object can be provided as the 2nd argument. The options object will be merged with the values
|
||||
* of {@link BaseRequestOptions} before performing the request.
|
||||
*/
|
||||
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
|
||||
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
|
||||
var responseObservable: any;
|
||||
if (isString(url)) {
|
||||
url =
|
||||
|
@ -7,9 +7,8 @@ export function normalizeMethodName(method: string | RequestMethod): RequestMeth
|
||||
if (isString(method)) {
|
||||
var originalMethod = method;
|
||||
method = (<string>method)
|
||||
.replace(
|
||||
/(\w)(\w*)/g,
|
||||
(g0: string, g1: string, g2: string) => g1.toUpperCase() + g2.toLowerCase());
|
||||
.replace(/(\w)(\w*)/g, (g0: string, g1: string, g2: string) =>
|
||||
g1.toUpperCase() + g2.toLowerCase());
|
||||
method = <number>(<{[key: string]: any}>RequestMethod)[method];
|
||||
if (typeof method !== 'number')
|
||||
throw makeTypeError(
|
||||
|
@ -28,8 +28,8 @@ export abstract class Connection {
|
||||
*/
|
||||
export interface RequestOptionsArgs {
|
||||
url?: string;
|
||||
method?: string|RequestMethod;
|
||||
search?: string|URLSearchParams;
|
||||
method?: string | RequestMethod;
|
||||
search?: string | URLSearchParams;
|
||||
headers?: Headers;
|
||||
// TODO: Support Blob, ArrayBuffer, JSON, URLSearchParams, FormData
|
||||
body?: string;
|
||||
@ -46,7 +46,10 @@ export interface RequestArgs extends RequestOptionsArgs { url: string; }
|
||||
*/
|
||||
export type ResponseOptionsArgs = {
|
||||
// TODO: Support Blob, ArrayBuffer, JSON
|
||||
body?: string | Object | FormData; status?: number; statusText?: string; headers?: Headers;
|
||||
body?: string | Object | FormData;
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
headers?: Headers;
|
||||
type?: ResponseType;
|
||||
url?: string;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@ import {RequestMethod} from './enums';
|
||||
import {RequestArgs} from './interfaces';
|
||||
import {Headers} from './headers';
|
||||
import {normalizeMethodName} from './http_utils';
|
||||
import {RegExpWrapper, CONST_EXPR, isPresent, isJsObject, StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
RegExpWrapper,
|
||||
CONST_EXPR,
|
||||
isPresent,
|
||||
isJsObject,
|
||||
StringWrapper
|
||||
} from 'angular2/src/facade/lang';
|
||||
|
||||
// TODO(jeffbcross): properly implement body accessors
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ export class Response {
|
||||
*/
|
||||
headers: Headers;
|
||||
// TODO: Support ArrayBuffer, JSON, FormData, Blob
|
||||
private _body: string|Object;
|
||||
private _body: string | Object;
|
||||
constructor(responseOptions: ResponseOptions) {
|
||||
this._body = responseOptions.body;
|
||||
this.status = responseOptions.status;
|
||||
@ -92,7 +92,7 @@ export class Response {
|
||||
* Attempts to return body as parsed `JSON` object, or raises an exception.
|
||||
*/
|
||||
json(): any {
|
||||
var jsonResponse: string|Object;
|
||||
var jsonResponse: string | Object;
|
||||
if (isJsObject(this._body)) {
|
||||
jsonResponse = this._body;
|
||||
} else if (isString(this._body)) {
|
||||
|
Reference in New Issue
Block a user