{"version":3,"file":"http.es5.js","sources":["../../../../packages/http/public_api.ts","../../../../packages/http/src/index.ts","../../../../packages/http/src/version.ts","../../../../packages/http/src/http_module.ts","../../../../packages/http/src/http.ts","../../../../packages/http/src/static_request.ts","../../../../packages/http/src/base_request_options.ts","../../../../packages/http/src/backends/xhr_backend.ts","../../../../packages/http/src/backends/jsonp_backend.ts","../../../../packages/http/src/backends/browser_jsonp.ts","../../../../packages/http/src/static_response.ts","../../../../packages/http/src/body.ts","../../../../packages/http/src/url_search_params.ts","../../../../packages/http/src/http_utils.ts","../../../../packages/http/src/interfaces.ts","../../../../packages/http/src/base_response_options.ts","../../../../packages/http/src/headers.ts","../../../../packages/http/src/enums.ts","../../../../packages/http/src/backends/browser_xhr.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the http package.\n */\nexport {BrowserXhr,JSONPBackend,JSONPConnection,CookieXSRFStrategy,XHRBackend,XHRConnection,BaseRequestOptions,RequestOptions,BaseResponseOptions,ResponseOptions,ReadyState,RequestMethod,ResponseContentType,ResponseType,Headers,Http,Jsonp,HttpModule,JsonpModule,Connection,ConnectionBackend,RequestOptionsArgs,ResponseOptionsArgs,XSRFStrategy,Request,Response,QueryEncoder,URLSearchParams,VERSION} from './src/index';\n\n// This file only reexports content of the `src` folder. Keep it that way.\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport {BrowserXhr} from './backends/browser_xhr';\nexport {JSONPBackend, JSONPConnection} from './backends/jsonp_backend';\nexport {CookieXSRFStrategy, XHRBackend, XHRConnection} from './backends/xhr_backend';\nexport {BaseRequestOptions, RequestOptions} from './base_request_options';\nexport {BaseResponseOptions, ResponseOptions} from './base_response_options';\nexport {ReadyState, RequestMethod, ResponseContentType, ResponseType} from './enums';\nexport {Headers} from './headers';\nexport {Http, Jsonp} from './http';\nexport {HttpModule, JsonpModule} from './http_module';\nexport {Connection, ConnectionBackend, RequestOptionsArgs, ResponseOptionsArgs, XSRFStrategy} from './interfaces';\nexport {Request} from './static_request';\nexport {Response} from './static_response';\nexport {QueryEncoder, URLSearchParams} from './url_search_params';\nexport {VERSION} from './version';\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the common package.\n */\n\n\nimport {Version} from '@angular/core';\n/**\n * \\@stable\n */\nexport const VERSION = new Version('4.4.6');\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * The http module provides services to perform http requests. To get started, see the {@link Http}\n * class.\n */\n\nimport {NgModule} from '@angular/core';\n\nimport {BrowserJsonp} from './backends/browser_jsonp';\nimport {BrowserXhr} from './backends/browser_xhr';\nimport {JSONPBackend, JSONPBackend_} from './backends/jsonp_backend';\nimport {CookieXSRFStrategy, XHRBackend} from './backends/xhr_backend';\nimport {BaseRequestOptions, RequestOptions} from './base_request_options';\nimport {BaseResponseOptions, ResponseOptions} from './base_response_options';\nimport {Http, Jsonp} from './http';\nimport {XSRFStrategy} from './interfaces';\n/**\n * @return {?}\n */\nexport function _createDefaultCookieXSRFStrategy() {\n return new CookieXSRFStrategy();\n}\n/**\n * @param {?} xhrBackend\n * @param {?} requestOptions\n * @return {?}\n */\nexport function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http {\n return new Http(xhrBackend, requestOptions);\n}\n/**\n * @param {?} jsonpBackend\n * @param {?} requestOptions\n * @return {?}\n */\nexport function jsonpFactory(jsonpBackend: JSONPBackend, requestOptions: RequestOptions): Jsonp {\n return new Jsonp(jsonpBackend, requestOptions);\n}\n/**\n * The module that includes http's providers\n * \n * \\@experimental\n */\nexport class HttpModule {\nstatic decorators: DecoratorInvocation[] = [\n{ type: NgModule, args: [{\n providers: [\n // TODO(pascal): use factory type annotations once supported in DI\n // issue: https://github.com/angular/angular/issues/3183\n {provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions]},\n BrowserXhr,\n {provide: RequestOptions, useClass: BaseRequestOptions},\n {provide: ResponseOptions, useClass: BaseResponseOptions},\n XHRBackend,\n {provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy},\n ],\n}, ] },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\nfunction HttpModule_tsickle_Closure_declarations() {\n/** @type {?} */\nHttpModule.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nHttpModule.ctorParameters;\n}\n\n/**\n * The module that includes jsonp's providers\n * \n * \\@experimental\n */\nexport class JsonpModule {\nstatic decorators: DecoratorInvocation[] = [\n{ type: NgModule, args: [{\n providers: [\n // TODO(pascal): use factory type annotations once supported in DI\n // issue: https://github.com/angular/angular/issues/3183\n {provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions]},\n BrowserJsonp,\n {provide: RequestOptions, useClass: BaseRequestOptions},\n {provide: ResponseOptions, useClass: BaseResponseOptions},\n {provide: JSONPBackend, useClass: JSONPBackend_},\n ],\n}, ] },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\nfunction JsonpModule_tsickle_Closure_declarations() {\n/** @type {?} */\nJsonpModule.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nJsonpModule.ctorParameters;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n\nimport {Injectable} from '@angular/core';\nimport {Observable} from 'rxjs/Observable';\n\nimport {BaseRequestOptions, RequestOptions} from './base_request_options';\nimport {RequestMethod} from './enums';\nimport {ConnectionBackend, RequestArgs, RequestOptionsArgs} from './interfaces';\nimport {Request} from './static_request';\nimport {Response} from './static_response';\n/**\n * @param {?} backend\n * @param {?} request\n * @return {?}\n */\nfunction httpRequest(backend: ConnectionBackend, request: Request): Observable {\n return backend.createConnection(request).response;\n}\n/**\n * @param {?} defaultOpts\n * @param {?} providedOpts\n * @param {?} method\n * @param {?} url\n * @return {?}\n */\nfunction mergeOptions(\n defaultOpts: BaseRequestOptions, providedOpts: RequestOptionsArgs | undefined,\n method: RequestMethod, url: string): RequestArgs {\n const /** @type {?} */ newOptions = defaultOpts;\n if (providedOpts) {\n // Hack so Dart can used named parameters\n return /** @type {?} */(( newOptions.merge(new RequestOptions({\n method: providedOpts.method || method,\n url: providedOpts.url || url,\n search: providedOpts.search,\n params: providedOpts.params,\n headers: providedOpts.headers,\n body: providedOpts.body,\n withCredentials: providedOpts.withCredentials,\n responseType: providedOpts.responseType\n })) as RequestArgs));\n }\n\n return /** @type {?} */(( newOptions.merge(new RequestOptions({method, url})) as RequestArgs));\n}\n/**\n * Performs http requests using `XMLHttpRequest` as the default backend.\n * \n * `Http` is available as an injectable class, with methods to perform http requests. Calling\n * `request` returns an `Observable` which will emit a single {\\@link Response} when a\n * response is received.\n * \n * ### Example\n * \n * ```typescript\n * import {Http, HTTP_PROVIDERS} from '\\@angular/http';\n * import 'rxjs/add/operator/map'\n * \\@Component({ \n * selector: 'http-app',\n * viewProviders: [HTTP_PROVIDERS],\n * templateUrl: 'people.html'\n * })\n * class PeopleComponent {\n * constructor(http: Http) {\n * http.get('people.json')\n * // Call map on the response observable to get the parsed people object\n * .map(res => res.json())\n * // Subscribe to the observable to get the parsed people object and attach it to the\n * // component\n * .subscribe(people => this.people = people);\n * }\n * }\n * ```\n * \n * \n * ### Example\n * \n * ```\n * http.get('people.json').subscribe((res:Response) => this.people = res.json());\n * ```\n * \n * The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a \"Backend\" (\n * {\\@link XHRBackend} in this case), which could be mocked with dependency injection by replacing\n * the {\\@link XHRBackend} provider, as in the following example:\n * \n * ### Example\n * \n * ```typescript\n * import {BaseRequestOptions, Http} from '\\@angular/http';\n * import {MockBackend} from '\\@angular/http/testing';\n * var injector = Injector.resolveAndCreate([\n * BaseRequestOptions,\n * MockBackend,\n * {provide: Http, useFactory:\n * function(backend, defaultOptions) {\n * return new Http(backend, defaultOptions);\n * },\n * deps: [MockBackend, BaseRequestOptions]}\n * ]);\n * var http = injector.get(Http);\n * http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));\n * ```\n * \n * \\@experimental\n */\nexport class Http {\n/**\n * @param {?} _backend\n * @param {?} _defaultOptions\n */\nconstructor(protected _backend: ConnectionBackend, protected _defaultOptions: RequestOptions) {}\n/**\n * Performs any type of http request. First argument is required, and can either be a url or\n * a {\\@link Request} instance. If the first argument is a url, an optional {\\@link RequestOptions}\n * object can be provided as the 2nd argument. The options object will be merged with the values\n * of {\\@link BaseRequestOptions} before performing the request.\n * @param {?} url\n * @param {?=} options\n * @return {?}\n */\nrequest(url: string|Request, options?: RequestOptionsArgs): Observable {\n let /** @type {?} */ responseObservable: any;\n if (typeof url === 'string') {\n responseObservable = httpRequest(\n this._backend,\n new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */(( url)))));\n } else if (url instanceof Request) {\n responseObservable = httpRequest(this._backend, url);\n } else {\n throw new Error('First argument must be a url string or Request instance.');\n }\n return responseObservable;\n }\n/**\n * Performs a request with `get` http method.\n * @param {?} url\n * @param {?=} options\n * @return {?}\n */\nget(url: string, options?: RequestOptionsArgs): Observable {\n return this.request(\n new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));\n }\n/**\n * Performs a request with `post` http method.\n * @param {?} url\n * @param {?} body\n * @param {?=} options\n * @return {?}\n */\npost(url: string, body: any, options?: RequestOptionsArgs): Observable {\n return this.request(new Request(mergeOptions(\n this._defaultOptions.merge(new RequestOptions({body: body})), options, RequestMethod.Post,\n url)));\n }\n/**\n * Performs a request with `put` http method.\n * @param {?} url\n * @param {?} body\n * @param {?=} options\n * @return {?}\n */\nput(url: string, body: any, options?: RequestOptionsArgs): Observable {\n return this.request(new Request(mergeOptions(\n this._defaultOptions.merge(new RequestOptions({body: body})), options, RequestMethod.Put,\n url)));\n }\n/**\n * Performs a request with `delete` http method.\n * @param {?} url\n * @param {?=} options\n * @return {?}\n */\ndelete (url: string, options?: RequestOptionsArgs): Observable {\n return this.request(\n new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));\n }\n/**\n * Performs a request with `patch` http method.\n * @param {?} url\n * @param {?} body\n * @param {?=} options\n * @return {?}\n */\npatch(url: string, body: any, options?: RequestOptionsArgs): Observable {\n return this.request(new Request(mergeOptions(\n this._defaultOptions.merge(new RequestOptions({body: body})), options, RequestMethod.Patch,\n url)));\n }\n/**\n * Performs a request with `head` http method.\n * @param {?} url\n * @param {?=} options\n * @return {?}\n */\nhead(url: string, options?: RequestOptionsArgs): Observable {\n return this.request(\n new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));\n }\n/**\n * Performs a request with `options` http method.\n * @param {?} url\n * @param {?=} options\n * @return {?}\n */\noptions(url: string, options?: RequestOptionsArgs): Observable {\n return this.request(\n new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: ConnectionBackend, },\n{type: RequestOptions, },\n];\n}\n\nfunction Http_tsickle_Closure_declarations() {\n/** @type {?} */\nHttp.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nHttp.ctorParameters;\n/** @type {?} */\nHttp.prototype._backend;\n/** @type {?} */\nHttp.prototype._defaultOptions;\n}\n\n/**\n * \\@experimental\n */\nexport class Jsonp extends Http {\n/**\n * @param {?} backend\n * @param {?} defaultOptions\n */\nconstructor(backend: ConnectionBackend, defaultOptions: RequestOptions) {\n super(backend, defaultOptions);\n }\n/**\n * Performs any type of http request. First argument is required, and can either be a url or\n * a {\\@link Request} instance. If the first argument is a url, an optional {\\@link RequestOptions}\n * object can be provided as the 2nd argument. The options object will be merged with the values\n * of {\\@link BaseRequestOptions} before performing the request.\n * \n * \\@security Regular XHR is the safest alternative to JSONP for most applications, and is\n * supported by all current browsers. Because JSONP creates a `