123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793 |
- /**
- * @license Angular v5.2.11
- * (c) 2010-2018 Google, Inc. https://angular.io/
- * License: MIT
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Observable'), require('@angular/platform-browser')) :
- typeof define === 'function' && define.amd ? define('@angular/http', ['exports', '@angular/core', 'rxjs/Observable', '@angular/platform-browser'], factory) :
- (factory((global.ng = global.ng || {}, global.ng.http = {}),global.ng.core,global.Rx,global.ng.platformBrowser));
- }(this, (function (exports,_angular_core,rxjs_Observable,_angular_platformBrowser) { 'use strict';
-
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
-
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
-
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- /* global Reflect, Promise */
-
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-
- function __extends(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
-
- /**
- * @license Angular v5.2.11
- * (c) 2010-2018 Google, Inc. https://angular.io/
- * License: MIT
- */
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A backend for http that uses the `XMLHttpRequest` browser API.
- *
- * Take care not to evaluate this in non-browser contexts.
- *
- * @deprecated use \@angular/common/http instead
- */
- var BrowserXhr = /** @class */ (function () {
- function BrowserXhr() {
- }
- /**
- * @return {?}
- */
- BrowserXhr.prototype.build = /**
- * @return {?}
- */
- function () { return /** @type {?} */ ((new XMLHttpRequest())); };
- BrowserXhr.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- BrowserXhr.ctorParameters = function () { return []; };
- return BrowserXhr;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var RequestMethod = {
- Get: 0,
- Post: 1,
- Put: 2,
- Delete: 3,
- Options: 4,
- Head: 5,
- Patch: 6,
- };
- RequestMethod[RequestMethod.Get] = "Get";
- RequestMethod[RequestMethod.Post] = "Post";
- RequestMethod[RequestMethod.Put] = "Put";
- RequestMethod[RequestMethod.Delete] = "Delete";
- RequestMethod[RequestMethod.Options] = "Options";
- RequestMethod[RequestMethod.Head] = "Head";
- RequestMethod[RequestMethod.Patch] = "Patch";
- /** @enum {number} */
- var ReadyState = {
- Unsent: 0,
- Open: 1,
- HeadersReceived: 2,
- Loading: 3,
- Done: 4,
- Cancelled: 5,
- };
- ReadyState[ReadyState.Unsent] = "Unsent";
- ReadyState[ReadyState.Open] = "Open";
- ReadyState[ReadyState.HeadersReceived] = "HeadersReceived";
- ReadyState[ReadyState.Loading] = "Loading";
- ReadyState[ReadyState.Done] = "Done";
- ReadyState[ReadyState.Cancelled] = "Cancelled";
- /** @enum {number} */
- var ResponseType = {
- Basic: 0,
- Cors: 1,
- Default: 2,
- Error: 3,
- Opaque: 4,
- };
- ResponseType[ResponseType.Basic] = "Basic";
- ResponseType[ResponseType.Cors] = "Cors";
- ResponseType[ResponseType.Default] = "Default";
- ResponseType[ResponseType.Error] = "Error";
- ResponseType[ResponseType.Opaque] = "Opaque";
- /** @enum {number} */
- var ContentType = {
- NONE: 0,
- JSON: 1,
- FORM: 2,
- FORM_DATA: 3,
- TEXT: 4,
- BLOB: 5,
- ARRAY_BUFFER: 6,
- };
- ContentType[ContentType.NONE] = "NONE";
- ContentType[ContentType.JSON] = "JSON";
- ContentType[ContentType.FORM] = "FORM";
- ContentType[ContentType.FORM_DATA] = "FORM_DATA";
- ContentType[ContentType.TEXT] = "TEXT";
- ContentType[ContentType.BLOB] = "BLOB";
- ContentType[ContentType.ARRAY_BUFFER] = "ARRAY_BUFFER";
- /** @enum {number} */
- var ResponseContentType = {
- Text: 0,
- Json: 1,
- ArrayBuffer: 2,
- Blob: 3,
- };
- ResponseContentType[ResponseContentType.Text] = "Text";
- ResponseContentType[ResponseContentType.Json] = "Json";
- ResponseContentType[ResponseContentType.ArrayBuffer] = "ArrayBuffer";
- ResponseContentType[ResponseContentType.Blob] = "Blob";
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
- * specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).
- *
- * The only known difference between this `Headers` implementation and the spec is the
- * lack of an `entries` method.
- *
- * ### Example
- *
- * ```
- * import {Headers} from '\@angular/http';
- *
- * var firstHeaders = new Headers();
- * firstHeaders.append('Content-Type', 'image/jpeg');
- * console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
- *
- * // Create headers from Plain Old JavaScript Object
- * var secondHeaders = new Headers({
- * 'X-My-Custom-Header': 'Angular'
- * });
- * console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
- *
- * var thirdHeaders = new Headers(secondHeaders);
- * console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var Headers = /** @class */ (function () {
- // TODO(vicb): any -> string|string[]
- function Headers(headers) {
- var _this = this;
- /**
- * \@internal header names are lower case
- */
- this._headers = new Map();
- /**
- * \@internal map lower case names to actual names
- */
- this._normalizedNames = new Map();
- if (!headers) {
- return;
- }
- if (headers instanceof Headers) {
- headers.forEach(function (values, name) {
- values.forEach(function (value) { return _this.append(name, value); });
- });
- return;
- }
- Object.keys(headers).forEach(function (name) {
- var /** @type {?} */ values = Array.isArray(headers[name]) ? headers[name] : [headers[name]];
- _this.delete(name);
- values.forEach(function (value) { return _this.append(name, value); });
- });
- }
- /**
- * Returns a new Headers instance from the given DOMString of Response Headers
- */
- /**
- * Returns a new Headers instance from the given DOMString of Response Headers
- * @param {?} headersString
- * @return {?}
- */
- Headers.fromResponseHeaderString = /**
- * Returns a new Headers instance from the given DOMString of Response Headers
- * @param {?} headersString
- * @return {?}
- */
- function (headersString) {
- var /** @type {?} */ headers = new Headers();
- headersString.split('\n').forEach(function (line) {
- var /** @type {?} */ index = line.indexOf(':');
- if (index > 0) {
- var /** @type {?} */ name_1 = line.slice(0, index);
- var /** @type {?} */ value = line.slice(index + 1).trim();
- headers.set(name_1, value);
- }
- });
- return headers;
- };
- /**
- * Appends a header to existing list of header values for a given header name.
- */
- /**
- * Appends a header to existing list of header values for a given header name.
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- Headers.prototype.append = /**
- * Appends a header to existing list of header values for a given header name.
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function (name, value) {
- var /** @type {?} */ values = this.getAll(name);
- if (values === null) {
- this.set(name, value);
- }
- else {
- values.push(value);
- }
- };
- /**
- * Deletes all header values for the given name.
- */
- /**
- * Deletes all header values for the given name.
- * @param {?} name
- * @return {?}
- */
- Headers.prototype.delete = /**
- * Deletes all header values for the given name.
- * @param {?} name
- * @return {?}
- */
- function (name) {
- var /** @type {?} */ lcName = name.toLowerCase();
- this._normalizedNames.delete(lcName);
- this._headers.delete(lcName);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- Headers.prototype.forEach = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- var _this = this;
- this._headers.forEach(function (values, lcName) { return fn(values, _this._normalizedNames.get(lcName), _this._headers); });
- };
- /**
- * Returns first header that matches given name.
- */
- /**
- * Returns first header that matches given name.
- * @param {?} name
- * @return {?}
- */
- Headers.prototype.get = /**
- * Returns first header that matches given name.
- * @param {?} name
- * @return {?}
- */
- function (name) {
- var /** @type {?} */ values = this.getAll(name);
- if (values === null) {
- return null;
- }
- return values.length > 0 ? values[0] : null;
- };
- /**
- * Checks for existence of header by given name.
- */
- /**
- * Checks for existence of header by given name.
- * @param {?} name
- * @return {?}
- */
- Headers.prototype.has = /**
- * Checks for existence of header by given name.
- * @param {?} name
- * @return {?}
- */
- function (name) { return this._headers.has(name.toLowerCase()); };
- /**
- * Returns the names of the headers
- */
- /**
- * Returns the names of the headers
- * @return {?}
- */
- Headers.prototype.keys = /**
- * Returns the names of the headers
- * @return {?}
- */
- function () { return Array.from(this._normalizedNames.values()); };
- /**
- * Sets or overrides header value for given name.
- */
- /**
- * Sets or overrides header value for given name.
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- Headers.prototype.set = /**
- * Sets or overrides header value for given name.
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function (name, value) {
- if (Array.isArray(value)) {
- if (value.length) {
- this._headers.set(name.toLowerCase(), [value.join(',')]);
- }
- }
- else {
- this._headers.set(name.toLowerCase(), [value]);
- }
- this.mayBeSetNormalizedName(name);
- };
- /**
- * Returns values of all headers.
- */
- /**
- * Returns values of all headers.
- * @return {?}
- */
- Headers.prototype.values = /**
- * Returns values of all headers.
- * @return {?}
- */
- function () { return Array.from(this._headers.values()); };
- /**
- * Returns string of all headers.
- */
- // TODO(vicb): returns {[name: string]: string[]}
- /**
- * Returns string of all headers.
- * @return {?}
- */
- Headers.prototype.toJSON = /**
- * Returns string of all headers.
- * @return {?}
- */
- function () {
- var _this = this;
- var /** @type {?} */ serialized = {};
- this._headers.forEach(function (values, name) {
- var /** @type {?} */ split = [];
- values.forEach(function (v) { return split.push.apply(split, v.split(',')); });
- serialized[/** @type {?} */ ((_this._normalizedNames.get(name)))] = split;
- });
- return serialized;
- };
- /**
- * Returns list of header values for a given name.
- */
- /**
- * Returns list of header values for a given name.
- * @param {?} name
- * @return {?}
- */
- Headers.prototype.getAll = /**
- * Returns list of header values for a given name.
- * @param {?} name
- * @return {?}
- */
- function (name) {
- return this.has(name) ? this._headers.get(name.toLowerCase()) || null : null;
- };
- /**
- * This method is not implemented.
- */
- /**
- * This method is not implemented.
- * @return {?}
- */
- Headers.prototype.entries = /**
- * This method is not implemented.
- * @return {?}
- */
- function () { throw new Error('"entries" method is not implemented on Headers class'); };
- /**
- * @param {?} name
- * @return {?}
- */
- Headers.prototype.mayBeSetNormalizedName = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- var /** @type {?} */ lcName = name.toLowerCase();
- if (!this._normalizedNames.has(lcName)) {
- this._normalizedNames.set(lcName, name);
- }
- };
- return Headers;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Creates a response options object to be optionally provided when instantiating a
- * {\@link Response}.
- *
- * This class is based on the `ResponseInit` description in the [Fetch
- * Spec](https://fetch.spec.whatwg.org/#responseinit).
- *
- * All values are null by default. Typical defaults can be found in the
- * {\@link BaseResponseOptions} class, which sub-classes `ResponseOptions`.
- *
- * This class may be used in tests to build {\@link Response Responses} for
- * mock responses (see {\@link MockBackend}).
- *
- * ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview))
- *
- * ```typescript
- * import {ResponseOptions, Response} from '\@angular/http';
- *
- * var options = new ResponseOptions({
- * body: '{"name":"Jeff"}'
- * });
- * var res = new Response(options);
- *
- * console.log('res.json():', res.json()); // Object {name: "Jeff"}
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var ResponseOptions = /** @class */ (function () {
- function ResponseOptions(opts) {
- if (opts === void 0) { opts = {}; }
- var body = opts.body, status = opts.status, headers = opts.headers, statusText = opts.statusText, type = opts.type, url = opts.url;
- this.body = body != null ? body : null;
- this.status = status != null ? status : null;
- this.headers = headers != null ? headers : null;
- this.statusText = statusText != null ? statusText : null;
- this.type = type != null ? type : null;
- this.url = url != null ? url : null;
- }
- /**
- * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
- * override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * This may be useful when sharing a base `ResponseOptions` object inside tests,
- * where certain properties may change from test to test.
- *
- * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
- *
- * ```typescript
- * import {ResponseOptions, Response} from '@angular/http';
- *
- * var options = new ResponseOptions({
- * body: {name: 'Jeff'}
- * });
- * var res = new Response(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('options.url:', options.url); // null
- * console.log('res.json():', res.json()); // Object {name: "Jeff"}
- * console.log('res.url:', res.url); // https://google.com
- * ```
- */
- /**
- * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
- * override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * This may be useful when sharing a base `ResponseOptions` object inside tests,
- * where certain properties may change from test to test.
- *
- * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
- *
- * ```typescript
- * import {ResponseOptions, Response} from '\@angular/http';
- *
- * var options = new ResponseOptions({
- * body: {name: 'Jeff'}
- * });
- * var res = new Response(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('options.url:', options.url); // null
- * console.log('res.json():', res.json()); // Object {name: "Jeff"}
- * console.log('res.url:', res.url); // https://google.com
- * ```
- * @param {?=} options
- * @return {?}
- */
- ResponseOptions.prototype.merge = /**
- * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
- * override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * This may be useful when sharing a base `ResponseOptions` object inside tests,
- * where certain properties may change from test to test.
- *
- * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
- *
- * ```typescript
- * import {ResponseOptions, Response} from '\@angular/http';
- *
- * var options = new ResponseOptions({
- * body: {name: 'Jeff'}
- * });
- * var res = new Response(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('options.url:', options.url); // null
- * console.log('res.json():', res.json()); // Object {name: "Jeff"}
- * console.log('res.url:', res.url); // https://google.com
- * ```
- * @param {?=} options
- * @return {?}
- */
- function (options) {
- return new ResponseOptions({
- body: options && options.body != null ? options.body : this.body,
- status: options && options.status != null ? options.status : this.status,
- headers: options && options.headers != null ? options.headers : this.headers,
- statusText: options && options.statusText != null ? options.statusText : this.statusText,
- type: options && options.type != null ? options.type : this.type,
- url: options && options.url != null ? options.url : this.url,
- });
- };
- return ResponseOptions;
- }());
- /**
- * Subclass of {\@link ResponseOptions}, with default values.
- *
- * Default values:
- * * status: 200
- * * headers: empty {\@link Headers} object
- *
- * This class could be extended and bound to the {\@link ResponseOptions} class
- * when configuring an {\@link Injector}, in order to override the default options
- * used by {\@link Http} to create {\@link Response Responses}.
- *
- * ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview))
- *
- * ```typescript
- * import {provide} from '\@angular/core';
- * import {bootstrap} from '\@angular/platform-browser/browser';
- * import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
- * '\@angular/http';
- * import {App} from './myapp';
- *
- * class MyOptions extends BaseResponseOptions {
- * headers:Headers = new Headers({network: 'github'});
- * }
- *
- * bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]);
- * ```
- *
- * The options could also be extended when manually creating a {\@link Response}
- * object.
- *
- * ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview))
- *
- * ```
- * import {BaseResponseOptions, Response} from '\@angular/http';
- *
- * var options = new BaseResponseOptions();
- * var res = new Response(options.merge({
- * body: 'Angular',
- * headers: new Headers({framework: 'angular'})
- * }));
- * console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
- * console.log('res.text():', res.text()); // Angular;
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var BaseResponseOptions = /** @class */ (function (_super) {
- __extends(BaseResponseOptions, _super);
- function BaseResponseOptions() {
- return _super.call(this, { status: 200, statusText: 'Ok', type: ResponseType.Default, headers: new Headers() }) || this;
- }
- BaseResponseOptions.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- BaseResponseOptions.ctorParameters = function () { return []; };
- return BaseResponseOptions;
- }(ResponseOptions));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Abstract class from which real backends are derived.
- *
- * The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
- * {\@link Request}.
- *
- * @deprecated use \@angular/common/http instead
- * @abstract
- */
- var ConnectionBackend = /** @class */ (function () {
- function ConnectionBackend() {
- }
- return ConnectionBackend;
- }());
- /**
- * Abstract class from which real connections are derived.
- *
- * @deprecated use \@angular/common/http instead
- * @abstract
- */
- var Connection = /** @class */ (function () {
- function Connection() {
- }
- return Connection;
- }());
- /**
- * An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.
- *
- * @deprecated use \@angular/common/http instead
- * @abstract
- */
- var XSRFStrategy = /** @class */ (function () {
- function XSRFStrategy() {
- }
- return XSRFStrategy;
- }());
- /**
- * Interface for options to construct a RequestOptions, based on
- * [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
- *
- * @deprecated use \@angular/common/http instead
- * @record
- */
-
- /**
- * Required structure when constructing new Request();
- * @record
- */
-
- /**
- * Interface for options to construct a Response, based on
- * [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
- *
- * @deprecated use \@angular/common/http instead
- * @record
- */
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} method
- * @return {?}
- */
- function normalizeMethodName(method) {
- if (typeof method !== 'string')
- return method;
- switch (method.toUpperCase()) {
- case 'GET':
- return RequestMethod.Get;
- case 'POST':
- return RequestMethod.Post;
- case 'PUT':
- return RequestMethod.Put;
- case 'DELETE':
- return RequestMethod.Delete;
- case 'OPTIONS':
- return RequestMethod.Options;
- case 'HEAD':
- return RequestMethod.Head;
- case 'PATCH':
- return RequestMethod.Patch;
- }
- throw new Error("Invalid request method. The method \"" + method + "\" is not supported.");
- }
- var isSuccess = function (status) { return (status >= 200 && status < 300); };
- /**
- * @param {?} xhr
- * @return {?}
- */
- function getResponseURL(xhr) {
- if ('responseURL' in xhr) {
- return xhr.responseURL;
- }
- if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
- return xhr.getResponseHeader('X-Request-URL');
- }
- return null;
- }
- /**
- * @param {?} input
- * @return {?}
- */
-
- /**
- * @param {?} input
- * @return {?}
- */
- function stringToArrayBuffer(input) {
- var /** @type {?} */ view = new Uint16Array(input.length);
- for (var /** @type {?} */ i = 0, /** @type {?} */ strLen = input.length; i < strLen; i++) {
- view[i] = input.charCodeAt(i);
- }
- return view.buffer;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?=} rawParams
- * @return {?}
- */
- function paramParser(rawParams) {
- if (rawParams === void 0) { rawParams = ''; }
- var /** @type {?} */ map = new Map();
- if (rawParams.length > 0) {
- var /** @type {?} */ params = rawParams.split('&');
- params.forEach(function (param) {
- var /** @type {?} */ eqIdx = param.indexOf('=');
- var _a = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)], key = _a[0], val = _a[1];
- var /** @type {?} */ list = map.get(key) || [];
- list.push(val);
- map.set(key, list);
- });
- }
- return map;
- }
- /**
- * @deprecated use \@angular/common/http instead
- *
- */
- var QueryEncoder = /** @class */ (function () {
- function QueryEncoder() {
- }
- /**
- * @param {?} k
- * @return {?}
- */
- QueryEncoder.prototype.encodeKey = /**
- * @param {?} k
- * @return {?}
- */
- function (k) { return standardEncoding(k); };
- /**
- * @param {?} v
- * @return {?}
- */
- QueryEncoder.prototype.encodeValue = /**
- * @param {?} v
- * @return {?}
- */
- function (v) { return standardEncoding(v); };
- return QueryEncoder;
- }());
- /**
- * @param {?} v
- * @return {?}
- */
- function standardEncoding(v) {
- return encodeURIComponent(v)
- .replace(/%40/gi, '@')
- .replace(/%3A/gi, ':')
- .replace(/%24/gi, '$')
- .replace(/%2C/gi, ',')
- .replace(/%3B/gi, ';')
- .replace(/%2B/gi, '+')
- .replace(/%3D/gi, '=')
- .replace(/%3F/gi, '?')
- .replace(/%2F/gi, '/');
- }
- /**
- * Map-like representation of url search parameters, based on
- * [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
- * with several extensions for merging URLSearchParams objects:
- * - setAll()
- * - appendAll()
- * - replaceAll()
- *
- * This class accepts an optional second parameter of ${\@link QueryEncoder},
- * which is used to serialize parameters before making a request. By default,
- * `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`,
- * and then un-encodes certain characters that are allowed to be part of the query
- * according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
- *
- * These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /`
- *
- * If the set of allowed query characters is not acceptable for a particular backend,
- * `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams.
- *
- * ```
- * import {URLSearchParams, QueryEncoder} from '\@angular/http';
- * class MyQueryEncoder extends QueryEncoder {
- * encodeKey(k: string): string {
- * return myEncodingFunction(k);
- * }
- *
- * encodeValue(v: string): string {
- * return myEncodingFunction(v);
- * }
- * }
- *
- * let params = new URLSearchParams('', new MyQueryEncoder());
- * ```
- * @deprecated use \@angular/common/http instead
- */
- var URLSearchParams = /** @class */ (function () {
- function URLSearchParams(rawParams, queryEncoder) {
- if (rawParams === void 0) { rawParams = ''; }
- if (queryEncoder === void 0) { queryEncoder = new QueryEncoder(); }
- this.rawParams = rawParams;
- this.queryEncoder = queryEncoder;
- this.paramsMap = paramParser(rawParams);
- }
- /**
- * @return {?}
- */
- URLSearchParams.prototype.clone = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ clone = new URLSearchParams('', this.queryEncoder);
- clone.appendAll(this);
- return clone;
- };
- /**
- * @param {?} param
- * @return {?}
- */
- URLSearchParams.prototype.has = /**
- * @param {?} param
- * @return {?}
- */
- function (param) { return this.paramsMap.has(param); };
- /**
- * @param {?} param
- * @return {?}
- */
- URLSearchParams.prototype.get = /**
- * @param {?} param
- * @return {?}
- */
- function (param) {
- var /** @type {?} */ storedParam = this.paramsMap.get(param);
- return Array.isArray(storedParam) ? storedParam[0] : null;
- };
- /**
- * @param {?} param
- * @return {?}
- */
- URLSearchParams.prototype.getAll = /**
- * @param {?} param
- * @return {?}
- */
- function (param) { return this.paramsMap.get(param) || []; };
- /**
- * @param {?} param
- * @param {?} val
- * @return {?}
- */
- URLSearchParams.prototype.set = /**
- * @param {?} param
- * @param {?} val
- * @return {?}
- */
- function (param, val) {
- if (val === void 0 || val === null) {
- this.delete(param);
- return;
- }
- var /** @type {?} */ list = this.paramsMap.get(param) || [];
- list.length = 0;
- list.push(val);
- this.paramsMap.set(param, list);
- };
- // A merge operation
- // For each name-values pair in `searchParams`, perform `set(name, values[0])`
- //
- // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4], c=[8], b=[7]"
- //
- // TODO(@caitp): document this better
- /**
- * @param {?} searchParams
- * @return {?}
- */
- URLSearchParams.prototype.setAll = /**
- * @param {?} searchParams
- * @return {?}
- */
- function (searchParams) {
- var _this = this;
- searchParams.paramsMap.forEach(function (value, param) {
- var /** @type {?} */ list = _this.paramsMap.get(param) || [];
- list.length = 0;
- list.push(value[0]);
- _this.paramsMap.set(param, list);
- });
- };
- /**
- * @param {?} param
- * @param {?} val
- * @return {?}
- */
- URLSearchParams.prototype.append = /**
- * @param {?} param
- * @param {?} val
- * @return {?}
- */
- function (param, val) {
- if (val === void 0 || val === null)
- return;
- var /** @type {?} */ list = this.paramsMap.get(param) || [];
- list.push(val);
- this.paramsMap.set(param, list);
- };
- // A merge operation
- // For each name-values pair in `searchParams`, perform `append(name, value)`
- // for each value in `values`.
- //
- // E.g: "a=[1,2], c=[8]" + "a=[3,4], b=[7]" = "a=[1,2,3,4], c=[8], b=[7]"
- //
- // TODO(@caitp): document this better
- /**
- * @param {?} searchParams
- * @return {?}
- */
- URLSearchParams.prototype.appendAll = /**
- * @param {?} searchParams
- * @return {?}
- */
- function (searchParams) {
- var _this = this;
- searchParams.paramsMap.forEach(function (value, param) {
- var /** @type {?} */ list = _this.paramsMap.get(param) || [];
- for (var /** @type {?} */ i = 0; i < value.length; ++i) {
- list.push(value[i]);
- }
- _this.paramsMap.set(param, list);
- });
- };
- // A merge operation
- // For each name-values pair in `searchParams`, perform `delete(name)`,
- // followed by `set(name, values)`
- //
- // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4,5,6], c=[8], b=[7]"
- //
- // TODO(@caitp): document this better
- /**
- * @param {?} searchParams
- * @return {?}
- */
- URLSearchParams.prototype.replaceAll = /**
- * @param {?} searchParams
- * @return {?}
- */
- function (searchParams) {
- var _this = this;
- searchParams.paramsMap.forEach(function (value, param) {
- var /** @type {?} */ list = _this.paramsMap.get(param) || [];
- list.length = 0;
- for (var /** @type {?} */ i = 0; i < value.length; ++i) {
- list.push(value[i]);
- }
- _this.paramsMap.set(param, list);
- });
- };
- /**
- * @return {?}
- */
- URLSearchParams.prototype.toString = /**
- * @return {?}
- */
- function () {
- var _this = this;
- var /** @type {?} */ paramsList = [];
- this.paramsMap.forEach(function (values, k) {
- values.forEach(function (v) {
- return paramsList.push(_this.queryEncoder.encodeKey(k) + '=' + _this.queryEncoder.encodeValue(v));
- });
- });
- return paramsList.join('&');
- };
- /**
- * @param {?} param
- * @return {?}
- */
- URLSearchParams.prototype.delete = /**
- * @param {?} param
- * @return {?}
- */
- function (param) { this.paramsMap.delete(param); };
- return URLSearchParams;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * HTTP request body used by both {\@link Request} and {\@link Response}
- * https://fetch.spec.whatwg.org/#body
- * @abstract
- */
- var Body = /** @class */ (function () {
- function Body() {
- }
- /**
- * Attempts to return body as parsed `JSON` object, or raises an exception.
- */
- /**
- * Attempts to return body as parsed `JSON` object, or raises an exception.
- * @return {?}
- */
- Body.prototype.json = /**
- * Attempts to return body as parsed `JSON` object, or raises an exception.
- * @return {?}
- */
- function () {
- if (typeof this._body === 'string') {
- return JSON.parse(/** @type {?} */ (this._body));
- }
- if (this._body instanceof ArrayBuffer) {
- return JSON.parse(this.text());
- }
- return this._body;
- };
- /**
- * Returns the body as a string, presuming `toString()` can be called on the response body.
- *
- * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
- * bytes in the buffer will be interpreted. Valid values are:
- *
- * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
- * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
- * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
- * into consideration. This is the default behavior to avoid breaking apps, but should be
- * considered deprecated.
- *
- * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
- */
- /**
- * Returns the body as a string, presuming `toString()` can be called on the response body.
- *
- * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
- * bytes in the buffer will be interpreted. Valid values are:
- *
- * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
- * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
- * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
- * into consideration. This is the default behavior to avoid breaking apps, but should be
- * considered deprecated.
- *
- * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
- * @param {?=} encodingHint
- * @return {?}
- */
- Body.prototype.text = /**
- * Returns the body as a string, presuming `toString()` can be called on the response body.
- *
- * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
- * bytes in the buffer will be interpreted. Valid values are:
- *
- * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
- * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
- * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
- * into consideration. This is the default behavior to avoid breaking apps, but should be
- * considered deprecated.
- *
- * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
- * @param {?=} encodingHint
- * @return {?}
- */
- function (encodingHint) {
- if (encodingHint === void 0) { encodingHint = 'legacy'; }
- if (this._body instanceof URLSearchParams) {
- return this._body.toString();
- }
- if (this._body instanceof ArrayBuffer) {
- switch (encodingHint) {
- case 'legacy':
- return String.fromCharCode.apply(null, new Uint16Array(/** @type {?} */ (this._body)));
- case 'iso-8859':
- return String.fromCharCode.apply(null, new Uint8Array(/** @type {?} */ (this._body)));
- default:
- throw new Error("Invalid value for encodingHint: " + encodingHint);
- }
- }
- if (this._body == null) {
- return '';
- }
- if (typeof this._body === 'object') {
- return JSON.stringify(this._body, null, 2);
- }
- return this._body.toString();
- };
- /**
- * Return the body as an ArrayBuffer
- */
- /**
- * Return the body as an ArrayBuffer
- * @return {?}
- */
- Body.prototype.arrayBuffer = /**
- * Return the body as an ArrayBuffer
- * @return {?}
- */
- function () {
- if (this._body instanceof ArrayBuffer) {
- return /** @type {?} */ (this._body);
- }
- return stringToArrayBuffer(this.text());
- };
- /**
- * Returns the request's body as a Blob, assuming that body exists.
- */
- /**
- * Returns the request's body as a Blob, assuming that body exists.
- * @return {?}
- */
- Body.prototype.blob = /**
- * Returns the request's body as a Blob, assuming that body exists.
- * @return {?}
- */
- function () {
- if (this._body instanceof Blob) {
- return /** @type {?} */ (this._body);
- }
- if (this._body instanceof ArrayBuffer) {
- return new Blob([this._body]);
- }
- throw new Error('The request body isn\'t either a blob or an array buffer');
- };
- return Body;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Creates `Response` instances from provided values.
- *
- * Though this object isn't
- * usually instantiated by end-users, it is the primary object interacted with when it comes time to
- * add data to a view.
- *
- * ### Example
- *
- * ```
- * http.request('my-friends.txt').subscribe(response => this.friends = response.text());
- * ```
- *
- * The Response's interface is inspired by the Response constructor defined in the [Fetch
- * Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
- * can be accessed many times. There are other differences in the implementation, but this is the
- * most significant.
- *
- * @deprecated use \@angular/common/http instead
- */
- var Response = /** @class */ (function (_super) {
- __extends(Response, _super);
- function Response(responseOptions) {
- var _this = _super.call(this) || this;
- _this._body = responseOptions.body;
- _this.status = /** @type {?} */ ((responseOptions.status));
- _this.ok = (_this.status >= 200 && _this.status <= 299);
- _this.statusText = responseOptions.statusText;
- _this.headers = responseOptions.headers;
- _this.type = /** @type {?} */ ((responseOptions.type));
- _this.url = /** @type {?} */ ((responseOptions.url));
- return _this;
- }
- /**
- * @return {?}
- */
- Response.prototype.toString = /**
- * @return {?}
- */
- function () {
- return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url;
- };
- return Response;
- }(Body));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _nextRequestId = 0;
- var JSONP_HOME = '__ng_jsonp__';
- var _jsonpConnections = null;
- /**
- * @return {?}
- */
- function _getJsonpConnections() {
- var /** @type {?} */ w = typeof window == 'object' ? window : {};
- if (_jsonpConnections === null) {
- _jsonpConnections = w[JSONP_HOME] = {};
- }
- return _jsonpConnections;
- }
- var BrowserJsonp = /** @class */ (function () {
- function BrowserJsonp() {
- }
- // Construct a <script> element with the specified URL
- /**
- * @param {?} url
- * @return {?}
- */
- BrowserJsonp.prototype.build = /**
- * @param {?} url
- * @return {?}
- */
- function (url) {
- var /** @type {?} */ node = document.createElement('script');
- node.src = url;
- return node;
- };
- /**
- * @return {?}
- */
- BrowserJsonp.prototype.nextRequestID = /**
- * @return {?}
- */
- function () { return "__req" + _nextRequestId++; };
- /**
- * @param {?} id
- * @return {?}
- */
- BrowserJsonp.prototype.requestCallback = /**
- * @param {?} id
- * @return {?}
- */
- function (id) { return JSONP_HOME + "." + id + ".finished"; };
- /**
- * @param {?} id
- * @param {?} connection
- * @return {?}
- */
- BrowserJsonp.prototype.exposeConnection = /**
- * @param {?} id
- * @param {?} connection
- * @return {?}
- */
- function (id, connection) {
- var /** @type {?} */ connections = _getJsonpConnections();
- connections[id] = connection;
- };
- /**
- * @param {?} id
- * @return {?}
- */
- BrowserJsonp.prototype.removeConnection = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- var /** @type {?} */ connections = _getJsonpConnections();
- connections[id] = null;
- };
- // Attach the <script> element to the DOM
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserJsonp.prototype.send = /**
- * @param {?} node
- * @return {?}
- */
- function (node) { document.body.appendChild(/** @type {?} */ ((node))); };
- // Remove <script> element from the DOM
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserJsonp.prototype.cleanup = /**
- * @param {?} node
- * @return {?}
- */
- function (node) {
- if (node.parentNode) {
- node.parentNode.removeChild(/** @type {?} */ ((node)));
- }
- };
- BrowserJsonp.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- BrowserJsonp.ctorParameters = function () { return []; };
- return BrowserJsonp;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
- var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
- /**
- * Base class for an in-flight JSONP request.
- *
- * @deprecated use \@angular/common/http instead
- */
- var JSONPConnection = /** @class */ (function () {
- /** @internal */
- function JSONPConnection(req, _dom, baseResponseOptions) {
- var _this = this;
- this._dom = _dom;
- this.baseResponseOptions = baseResponseOptions;
- this._finished = false;
- if (req.method !== RequestMethod.Get) {
- throw new TypeError(JSONP_ERR_WRONG_METHOD);
- }
- this.request = req;
- this.response = new rxjs_Observable.Observable(function (responseObserver) {
- _this.readyState = ReadyState.Loading;
- var /** @type {?} */ id = _this._id = _dom.nextRequestID();
- _dom.exposeConnection(id, _this);
- // Workaround Dart
- // url = url.replace(/=JSONP_CALLBACK(&|$)/, `generated method`);
- var /** @type {?} */ callback = _dom.requestCallback(_this._id);
- var /** @type {?} */ url = req.url;
- if (url.indexOf('=JSONP_CALLBACK&') > -1) {
- url = url.replace('=JSONP_CALLBACK&', "=" + callback + "&");
- }
- else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
- url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + ("=" + callback);
- }
- var /** @type {?} */ script = _this._script = _dom.build(url);
- var /** @type {?} */ onLoad = function (event) {
- if (_this.readyState === ReadyState.Cancelled)
- return;
- _this.readyState = ReadyState.Done;
- _dom.cleanup(script);
- if (!_this._finished) {
- var /** @type {?} */ responseOptions_1 = new ResponseOptions({ body: JSONP_ERR_NO_CALLBACK, type: ResponseType.Error, url: url });
- if (baseResponseOptions) {
- responseOptions_1 = baseResponseOptions.merge(responseOptions_1);
- }
- responseObserver.error(new Response(responseOptions_1));
- return;
- }
- var /** @type {?} */ responseOptions = new ResponseOptions({ body: _this._responseData, url: url });
- if (_this.baseResponseOptions) {
- responseOptions = _this.baseResponseOptions.merge(responseOptions);
- }
- responseObserver.next(new Response(responseOptions));
- responseObserver.complete();
- };
- var /** @type {?} */ onError = function (error) {
- if (_this.readyState === ReadyState.Cancelled)
- return;
- _this.readyState = ReadyState.Done;
- _dom.cleanup(script);
- var /** @type {?} */ responseOptions = new ResponseOptions({ body: error.message, type: ResponseType.Error });
- if (baseResponseOptions) {
- responseOptions = baseResponseOptions.merge(responseOptions);
- }
- responseObserver.error(new Response(responseOptions));
- };
- script.addEventListener('load', onLoad);
- script.addEventListener('error', onError);
- _dom.send(script);
- return function () {
- _this.readyState = ReadyState.Cancelled;
- script.removeEventListener('load', onLoad);
- script.removeEventListener('error', onError);
- _this._dom.cleanup(script);
- };
- });
- }
- /**
- * Callback called when the JSONP request completes, to notify the application
- * of the new data.
- */
- /**
- * Callback called when the JSONP request completes, to notify the application
- * of the new data.
- * @param {?=} data
- * @return {?}
- */
- JSONPConnection.prototype.finished = /**
- * Callback called when the JSONP request completes, to notify the application
- * of the new data.
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- // Don't leak connections
- this._finished = true;
- this._dom.removeConnection(this._id);
- if (this.readyState === ReadyState.Cancelled)
- return;
- this._responseData = data;
- };
- return JSONPConnection;
- }());
- /**
- * A {\@link ConnectionBackend} that uses the JSONP strategy of making requests.
- *
- * @deprecated use \@angular/common/http instead
- */
- var JSONPBackend = /** @class */ (function (_super) {
- __extends(JSONPBackend, _super);
- /** @internal */
- function JSONPBackend(_browserJSONP, _baseResponseOptions) {
- var _this = _super.call(this) || this;
- _this._browserJSONP = _browserJSONP;
- _this._baseResponseOptions = _baseResponseOptions;
- return _this;
- }
- /**
- * @param {?} request
- * @return {?}
- */
- JSONPBackend.prototype.createConnection = /**
- * @param {?} request
- * @return {?}
- */
- function (request) {
- return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);
- };
- JSONPBackend.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- JSONPBackend.ctorParameters = function () { return [
- { type: BrowserJsonp, },
- { type: ResponseOptions, },
- ]; };
- return JSONPBackend;
- }(ConnectionBackend));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var XSSI_PREFIX = /^\)\]\}',?\n/;
- /**
- * Creates connections using `XMLHttpRequest`. Given a fully-qualified
- * request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
- * request.
- *
- * This class would typically not be created or interacted with directly inside applications, though
- * the {\@link MockConnection} may be interacted with in tests.
- *
- * @deprecated use \@angular/common/http instead
- */
- var XHRConnection = /** @class */ (function () {
- function XHRConnection(req, browserXHR, baseResponseOptions) {
- var _this = this;
- this.request = req;
- this.response = new rxjs_Observable.Observable(function (responseObserver) {
- var /** @type {?} */ _xhr = browserXHR.build();
- _xhr.open(RequestMethod[req.method].toUpperCase(), req.url);
- if (req.withCredentials != null) {
- _xhr.withCredentials = req.withCredentials;
- }
- // load event handler
- var /** @type {?} */ onLoad = function () {
- // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
- var /** @type {?} */ status = _xhr.status === 1223 ? 204 : _xhr.status;
- var /** @type {?} */ body = null;
- // HTTP 204 means no content
- if (status !== 204) {
- // responseText is the old-school way of retrieving response (supported by IE8 & 9)
- // response/responseType properties were introduced in ResourceLoader Level2 spec
- // (supported by IE10)
- body = (typeof _xhr.response === 'undefined') ? _xhr.responseText : _xhr.response;
- // Implicitly strip a potential XSSI prefix.
- if (typeof body === 'string') {
- body = body.replace(XSSI_PREFIX, '');
- }
- }
- // fix status code when it is 0 (0 status is undocumented).
- // Occurs when accessing file resources or on Android 4.1 stock browser
- // while retrieving files from application cache.
- if (status === 0) {
- status = body ? 200 : 0;
- }
- var /** @type {?} */ headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
- // IE 9 does not provide the way to get URL of response
- var /** @type {?} */ url = getResponseURL(_xhr) || req.url;
- var /** @type {?} */ statusText = _xhr.statusText || 'OK';
- var /** @type {?} */ responseOptions = new ResponseOptions({ body: body, status: status, headers: headers, statusText: statusText, url: url });
- if (baseResponseOptions != null) {
- responseOptions = baseResponseOptions.merge(responseOptions);
- }
- var /** @type {?} */ response = new Response(responseOptions);
- response.ok = isSuccess(status);
- if (response.ok) {
- responseObserver.next(response);
- // TODO(gdi2290): defer complete if array buffer until done
- responseObserver.complete();
- return;
- }
- responseObserver.error(response);
- };
- // error event handler
- var /** @type {?} */ onError = function (err) {
- var /** @type {?} */ responseOptions = new ResponseOptions({
- body: err,
- type: ResponseType.Error,
- status: _xhr.status,
- statusText: _xhr.statusText,
- });
- if (baseResponseOptions != null) {
- responseOptions = baseResponseOptions.merge(responseOptions);
- }
- responseObserver.error(new Response(responseOptions));
- };
- _this.setDetectedContentType(req, _xhr);
- if (req.headers == null) {
- req.headers = new Headers();
- }
- if (!req.headers.has('Accept')) {
- req.headers.append('Accept', 'application/json, text/plain, */*');
- }
- req.headers.forEach(function (values, name) { return _xhr.setRequestHeader(/** @type {?} */ ((name)), values.join(',')); });
- // Select the correct buffer type to store the response
- if (req.responseType != null && _xhr.responseType != null) {
- switch (req.responseType) {
- case ResponseContentType.ArrayBuffer:
- _xhr.responseType = 'arraybuffer';
- break;
- case ResponseContentType.Json:
- _xhr.responseType = 'json';
- break;
- case ResponseContentType.Text:
- _xhr.responseType = 'text';
- break;
- case ResponseContentType.Blob:
- _xhr.responseType = 'blob';
- break;
- default:
- throw new Error('The selected responseType is not supported');
- }
- }
- _xhr.addEventListener('load', onLoad);
- _xhr.addEventListener('error', onError);
- _xhr.send(_this.request.getBody());
- return function () {
- _xhr.removeEventListener('load', onLoad);
- _xhr.removeEventListener('error', onError);
- _xhr.abort();
- };
- });
- }
- /**
- * @param {?} req
- * @param {?} _xhr
- * @return {?}
- */
- XHRConnection.prototype.setDetectedContentType = /**
- * @param {?} req
- * @param {?} _xhr
- * @return {?}
- */
- function (req /** TODO Request */, _xhr /** XMLHttpRequest */) {
- // Skip if a custom Content-Type header is provided
- if (req.headers != null && req.headers.get('Content-Type') != null) {
- return;
- }
- // Set the detected content type
- switch (req.contentType) {
- case ContentType.NONE:
- break;
- case ContentType.JSON:
- _xhr.setRequestHeader('content-type', 'application/json');
- break;
- case ContentType.FORM:
- _xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
- break;
- case ContentType.TEXT:
- _xhr.setRequestHeader('content-type', 'text/plain');
- break;
- case ContentType.BLOB:
- var /** @type {?} */ blob = req.blob();
- if (blob.type) {
- _xhr.setRequestHeader('content-type', blob.type);
- }
- break;
- }
- };
- return XHRConnection;
- }());
- /**
- * `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
- * using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
- * for more information on XSRF.
- *
- * Applications can configure custom cookie and header names by binding an instance of this class
- * with different `cookieName` and `headerName` values. See the main HTTP documentation for more
- * details.
- *
- * @deprecated use \@angular/common/http instead
- */
- var CookieXSRFStrategy = /** @class */ (function () {
- function CookieXSRFStrategy(_cookieName, _headerName) {
- if (_cookieName === void 0) { _cookieName = 'XSRF-TOKEN'; }
- if (_headerName === void 0) { _headerName = 'X-XSRF-TOKEN'; }
- this._cookieName = _cookieName;
- this._headerName = _headerName;
- }
- /**
- * @param {?} req
- * @return {?}
- */
- CookieXSRFStrategy.prototype.configureRequest = /**
- * @param {?} req
- * @return {?}
- */
- function (req) {
- var /** @type {?} */ xsrfToken = _angular_platformBrowser.ɵgetDOM().getCookie(this._cookieName);
- if (xsrfToken) {
- req.headers.set(this._headerName, xsrfToken);
- }
- };
- return CookieXSRFStrategy;
- }());
- /**
- * Creates {\@link XHRConnection} instances.
- *
- * This class would typically not be used by end users, but could be
- * overridden if a different backend implementation should be used,
- * such as in a node backend.
- *
- * ### Example
- *
- * ```
- * import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '\@angular/http';
- * \@Component({
- * viewProviders: [
- * HTTP_PROVIDERS,
- * {provide: Http, useFactory: (backend, options) => {
- * return new Http(backend, options);
- * }, deps: [MyNodeBackend, BaseRequestOptions]}]
- * })
- * class MyComponent {
- * constructor(http:Http) {
- * http.request('people.json').subscribe(res => this.people = res.json());
- * }
- * }
- * ```
- * @deprecated use \@angular/common/http instead
- */
- var XHRBackend = /** @class */ (function () {
- function XHRBackend(_browserXHR, _baseResponseOptions, _xsrfStrategy) {
- this._browserXHR = _browserXHR;
- this._baseResponseOptions = _baseResponseOptions;
- this._xsrfStrategy = _xsrfStrategy;
- }
- /**
- * @param {?} request
- * @return {?}
- */
- XHRBackend.prototype.createConnection = /**
- * @param {?} request
- * @return {?}
- */
- function (request) {
- this._xsrfStrategy.configureRequest(request);
- return new XHRConnection(request, this._browserXHR, this._baseResponseOptions);
- };
- XHRBackend.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- XHRBackend.ctorParameters = function () { return [
- { type: BrowserXhr, },
- { type: ResponseOptions, },
- { type: XSRFStrategy, },
- ]; };
- return XHRBackend;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Creates a request options object to be optionally provided when instantiating a
- * {\@link Request}.
- *
- * This class is based on the `RequestInit` description in the [Fetch
- * Spec](https://fetch.spec.whatwg.org/#requestinit).
- *
- * All values are null by default. Typical defaults can be found in the {\@link BaseRequestOptions}
- * class, which sub-classes `RequestOptions`.
- *
- * ```typescript
- * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
- *
- * const options = new RequestOptions({
- * method: RequestMethod.Post,
- * url: 'https://google.com'
- * });
- * const req = new Request(options);
- * console.log('req.method:', RequestMethod[req.method]); // Post
- * console.log('options.url:', options.url); // https://google.com
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var RequestOptions = /** @class */ (function () {
- // TODO(Dzmitry): remove search when this.search is removed
- function RequestOptions(opts) {
- if (opts === void 0) { opts = {}; }
- var method = opts.method, headers = opts.headers, body = opts.body, url = opts.url, search = opts.search, params = opts.params, withCredentials = opts.withCredentials, responseType = opts.responseType;
- this.method = method != null ? normalizeMethodName(method) : null;
- this.headers = headers != null ? headers : null;
- this.body = body != null ? body : null;
- this.url = url != null ? url : null;
- this.params = this._mergeSearchParams(params || search);
- this.withCredentials = withCredentials != null ? withCredentials : null;
- this.responseType = responseType != null ? responseType : null;
- }
- Object.defineProperty(RequestOptions.prototype, "search", {
- /**
- * @deprecated from 4.0.0. Use params instead.
- */
- get: /**
- * @deprecated from 4.0.0. Use params instead.
- * @return {?}
- */
- function () { return this.params; },
- /**
- * @deprecated from 4.0.0. Use params instead.
- */
- set: /**
- * @deprecated from 4.0.0. Use params instead.
- * @param {?} params
- * @return {?}
- */
- function (params) { this.params = params; },
- enumerable: true,
- configurable: true
- });
- /**
- * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * Note that `headers` and `search` will override existing values completely if present in
- * the `options` object. If these values should be merged, it should be done prior to calling
- * `merge` on the `RequestOptions` instance.
- *
- * ```typescript
- * import {RequestOptions, Request, RequestMethod} from '@angular/http';
- *
- * const options = new RequestOptions({
- * method: RequestMethod.Post
- * });
- * const req = new Request(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('req.method:', RequestMethod[req.method]); // Post
- * console.log('options.url:', options.url); // null
- * console.log('req.url:', req.url); // https://google.com
- * ```
- */
- /**
- * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * Note that `headers` and `search` will override existing values completely if present in
- * the `options` object. If these values should be merged, it should be done prior to calling
- * `merge` on the `RequestOptions` instance.
- *
- * ```typescript
- * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
- *
- * const options = new RequestOptions({
- * method: RequestMethod.Post
- * });
- * const req = new Request(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('req.method:', RequestMethod[req.method]); // Post
- * console.log('options.url:', options.url); // null
- * console.log('req.url:', req.url); // https://google.com
- * ```
- * @param {?=} options
- * @return {?}
- */
- RequestOptions.prototype.merge = /**
- * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
- * existing values. This method will not change the values of the instance on which it is being
- * called.
- *
- * Note that `headers` and `search` will override existing values completely if present in
- * the `options` object. If these values should be merged, it should be done prior to calling
- * `merge` on the `RequestOptions` instance.
- *
- * ```typescript
- * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
- *
- * const options = new RequestOptions({
- * method: RequestMethod.Post
- * });
- * const req = new Request(options.merge({
- * url: 'https://google.com'
- * }));
- * console.log('req.method:', RequestMethod[req.method]); // Post
- * console.log('options.url:', options.url); // null
- * console.log('req.url:', req.url); // https://google.com
- * ```
- * @param {?=} options
- * @return {?}
- */
- function (options) {
- return new RequestOptions({
- method: options && options.method != null ? options.method : this.method,
- headers: options && options.headers != null ? options.headers : new Headers(this.headers),
- body: options && options.body != null ? options.body : this.body,
- url: options && options.url != null ? options.url : this.url,
- params: options && this._mergeSearchParams(options.params || options.search),
- withCredentials: options && options.withCredentials != null ? options.withCredentials :
- this.withCredentials,
- responseType: options && options.responseType != null ? options.responseType :
- this.responseType
- });
- };
- /**
- * @param {?=} params
- * @return {?}
- */
- RequestOptions.prototype._mergeSearchParams = /**
- * @param {?=} params
- * @return {?}
- */
- function (params) {
- if (!params)
- return this.params;
- if (params instanceof URLSearchParams) {
- return params.clone();
- }
- if (typeof params === 'string') {
- return new URLSearchParams(params);
- }
- return this._parseParams(params);
- };
- /**
- * @param {?=} objParams
- * @return {?}
- */
- RequestOptions.prototype._parseParams = /**
- * @param {?=} objParams
- * @return {?}
- */
- function (objParams) {
- var _this = this;
- if (objParams === void 0) { objParams = {}; }
- var /** @type {?} */ params = new URLSearchParams();
- Object.keys(objParams).forEach(function (key) {
- var /** @type {?} */ value = objParams[key];
- if (Array.isArray(value)) {
- value.forEach(function (item) { return _this._appendParam(key, item, params); });
- }
- else {
- _this._appendParam(key, value, params);
- }
- });
- return params;
- };
- /**
- * @param {?} key
- * @param {?} value
- * @param {?} params
- * @return {?}
- */
- RequestOptions.prototype._appendParam = /**
- * @param {?} key
- * @param {?} value
- * @param {?} params
- * @return {?}
- */
- function (key, value, params) {
- if (typeof value !== 'string') {
- value = JSON.stringify(value);
- }
- params.append(key, value);
- };
- return RequestOptions;
- }());
- /**
- * Subclass of {\@link RequestOptions}, with default values.
- *
- * Default values:
- * * method: {\@link RequestMethod RequestMethod.Get}
- * * headers: empty {\@link Headers} object
- *
- * This class could be extended and bound to the {\@link RequestOptions} class
- * when configuring an {\@link Injector}, in order to override the default options
- * used by {\@link Http} to create and send {\@link Request Requests}.
- *
- * ```typescript
- * import {BaseRequestOptions, RequestOptions} from '\@angular/http';
- *
- * class MyOptions extends BaseRequestOptions {
- * search: string = 'coreTeam=true';
- * }
- *
- * {provide: RequestOptions, useClass: MyOptions};
- * ```
- *
- * The options could also be extended when manually creating a {\@link Request}
- * object.
- *
- * ```
- * import {BaseRequestOptions, Request, RequestMethod} from '\@angular/http';
- *
- * const options = new BaseRequestOptions();
- * const req = new Request(options.merge({
- * method: RequestMethod.Post,
- * url: 'https://google.com'
- * }));
- * console.log('req.method:', RequestMethod[req.method]); // Post
- * console.log('options.url:', options.url); // null
- * console.log('req.url:', req.url); // https://google.com
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var BaseRequestOptions = /** @class */ (function (_super) {
- __extends(BaseRequestOptions, _super);
- function BaseRequestOptions() {
- return _super.call(this, { method: RequestMethod.Get, headers: new Headers() }) || this;
- }
- BaseRequestOptions.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- BaseRequestOptions.ctorParameters = function () { return []; };
- return BaseRequestOptions;
- }(RequestOptions));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Creates `Request` instances from provided values.
- *
- * The Request's interface is inspired by the Request constructor defined in the [Fetch
- * Spec](https://fetch.spec.whatwg.org/#request-class),
- * but is considered a static value whose body can be accessed many times. There are other
- * differences in the implementation, but this is the most significant.
- *
- * `Request` instances are typically created by higher-level classes, like {\@link Http} and
- * {\@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
- * One such example is when creating services that wrap higher-level services, like {\@link Http},
- * where it may be useful to generate a `Request` with arbitrary headers and search params.
- *
- * ```typescript
- * import {Injectable, Injector} from '\@angular/core';
- * import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '\@angular/http';
- *
- * \@Injectable()
- * class AutoAuthenticator {
- * constructor(public http:Http) {}
- * request(url:string) {
- * return this.http.request(new Request({
- * method: RequestMethod.Get,
- * url: url,
- * search: 'password=123'
- * }));
- * }
- * }
- *
- * var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
- * var authenticator = injector.get(AutoAuthenticator);
- * authenticator.request('people.json').subscribe(res => {
- * //URL should have included '?password=123'
- * console.log('people', res.json());
- * });
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var Request = /** @class */ (function (_super) {
- __extends(Request, _super);
- function Request(requestOptions) {
- var _this = _super.call(this) || this;
- // TODO: assert that url is present
- var /** @type {?} */ url = requestOptions.url;
- _this.url = /** @type {?} */ ((requestOptions.url));
- var /** @type {?} */ paramsArg = requestOptions.params || requestOptions.search;
- if (paramsArg) {
- var /** @type {?} */ params = void 0;
- if (typeof paramsArg === 'object' && !(paramsArg instanceof URLSearchParams)) {
- params = urlEncodeParams(paramsArg).toString();
- }
- else {
- params = paramsArg.toString();
- }
- if (params.length > 0) {
- var /** @type {?} */ prefix = '?';
- if (_this.url.indexOf('?') != -1) {
- prefix = (_this.url[_this.url.length - 1] == '&') ? '' : '&';
- }
- // TODO: just delete search-query-looking string in url?
- // TODO: just delete search-query-looking string in url?
- _this.url = url + prefix + params;
- }
- }
- _this._body = requestOptions.body;
- _this.method = normalizeMethodName(/** @type {?} */ ((requestOptions.method)));
- // TODO(jeffbcross): implement behavior
- // Defaults to 'omit', consistent with browser
- // TODO(jeffbcross): implement behavior
- // Defaults to 'omit', consistent with browser
- _this.headers = new Headers(requestOptions.headers);
- _this.contentType = _this.detectContentType();
- _this.withCredentials = /** @type {?} */ ((requestOptions.withCredentials));
- _this.responseType = /** @type {?} */ ((requestOptions.responseType));
- return _this;
- }
- /**
- * Returns the content type enum based on header options.
- */
- /**
- * Returns the content type enum based on header options.
- * @return {?}
- */
- Request.prototype.detectContentType = /**
- * Returns the content type enum based on header options.
- * @return {?}
- */
- function () {
- switch (this.headers.get('content-type')) {
- case 'application/json':
- return ContentType.JSON;
- case 'application/x-www-form-urlencoded':
- return ContentType.FORM;
- case 'multipart/form-data':
- return ContentType.FORM_DATA;
- case 'text/plain':
- case 'text/html':
- return ContentType.TEXT;
- case 'application/octet-stream':
- return this._body instanceof ArrayBuffer$1 ? ContentType.ARRAY_BUFFER : ContentType.BLOB;
- default:
- return this.detectContentTypeFromBody();
- }
- };
- /**
- * Returns the content type of request's body based on its type.
- */
- /**
- * Returns the content type of request's body based on its type.
- * @return {?}
- */
- Request.prototype.detectContentTypeFromBody = /**
- * Returns the content type of request's body based on its type.
- * @return {?}
- */
- function () {
- if (this._body == null) {
- return ContentType.NONE;
- }
- else if (this._body instanceof URLSearchParams) {
- return ContentType.FORM;
- }
- else if (this._body instanceof FormData) {
- return ContentType.FORM_DATA;
- }
- else if (this._body instanceof Blob$1) {
- return ContentType.BLOB;
- }
- else if (this._body instanceof ArrayBuffer$1) {
- return ContentType.ARRAY_BUFFER;
- }
- else if (this._body && typeof this._body === 'object') {
- return ContentType.JSON;
- }
- else {
- return ContentType.TEXT;
- }
- };
- /**
- * Returns the request's body according to its type. If body is undefined, return
- * null.
- */
- /**
- * Returns the request's body according to its type. If body is undefined, return
- * null.
- * @return {?}
- */
- Request.prototype.getBody = /**
- * Returns the request's body according to its type. If body is undefined, return
- * null.
- * @return {?}
- */
- function () {
- switch (this.contentType) {
- case ContentType.JSON:
- return this.text();
- case ContentType.FORM:
- return this.text();
- case ContentType.FORM_DATA:
- return this._body;
- case ContentType.TEXT:
- return this.text();
- case ContentType.BLOB:
- return this.blob();
- case ContentType.ARRAY_BUFFER:
- return this.arrayBuffer();
- default:
- return null;
- }
- };
- return Request;
- }(Body));
- /**
- * @param {?} params
- * @return {?}
- */
- function urlEncodeParams(params) {
- var /** @type {?} */ searchParams = new URLSearchParams();
- Object.keys(params).forEach(function (key) {
- var /** @type {?} */ value = params[key];
- if (value && Array.isArray(value)) {
- value.forEach(function (element) { return searchParams.append(key, element.toString()); });
- }
- else {
- searchParams.append(key, value.toString());
- }
- });
- return searchParams;
- }
- var noop = function () { };
- var w = typeof window == 'object' ? window : noop;
- var FormData = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['FormData'] || noop;
- var Blob$1 = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['Blob'] || noop;
- var ArrayBuffer$1 = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['ArrayBuffer'] || noop;
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} backend
- * @param {?} request
- * @return {?}
- */
- function httpRequest(backend, request) {
- return backend.createConnection(request).response;
- }
- /**
- * @param {?} defaultOpts
- * @param {?} providedOpts
- * @param {?} method
- * @param {?} url
- * @return {?}
- */
- function mergeOptions(defaultOpts, providedOpts, method, url) {
- var /** @type {?} */ newOptions = defaultOpts;
- if (providedOpts) {
- // Hack so Dart can used named parameters
- return /** @type {?} */ (newOptions.merge(new RequestOptions({
- method: providedOpts.method || method,
- url: providedOpts.url || url,
- search: providedOpts.search,
- params: providedOpts.params,
- headers: providedOpts.headers,
- body: providedOpts.body,
- withCredentials: providedOpts.withCredentials,
- responseType: providedOpts.responseType
- })));
- }
- return /** @type {?} */ (newOptions.merge(new RequestOptions({ method: method, url: url })));
- }
- /**
- * Performs http requests using `XMLHttpRequest` as the default backend.
- *
- * `Http` is available as an injectable class, with methods to perform http requests. Calling
- * `request` returns an `Observable` which will emit a single {\@link Response} when a
- * response is received.
- *
- * ### Example
- *
- * ```typescript
- * import {Http, HTTP_PROVIDERS} from '\@angular/http';
- * import 'rxjs/add/operator/map'
- * \@Component({
- * selector: 'http-app',
- * viewProviders: [HTTP_PROVIDERS],
- * templateUrl: 'people.html'
- * })
- * class PeopleComponent {
- * constructor(http: Http) {
- * http.get('people.json')
- * // Call map on the response observable to get the parsed people object
- * .map(res => res.json())
- * // Subscribe to the observable to get the parsed people object and attach it to the
- * // component
- * .subscribe(people => this.people = people);
- * }
- * }
- * ```
- *
- *
- * ### Example
- *
- * ```
- * http.get('people.json').subscribe((res:Response) => this.people = res.json());
- * ```
- *
- * The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" (
- * {\@link XHRBackend} in this case), which could be mocked with dependency injection by replacing
- * the {\@link XHRBackend} provider, as in the following example:
- *
- * ### Example
- *
- * ```typescript
- * import {BaseRequestOptions, Http} from '\@angular/http';
- * import {MockBackend} from '\@angular/http/testing';
- * var injector = Injector.resolveAndCreate([
- * BaseRequestOptions,
- * MockBackend,
- * {provide: Http, useFactory:
- * function(backend, defaultOptions) {
- * return new Http(backend, defaultOptions);
- * },
- * deps: [MockBackend, BaseRequestOptions]}
- * ]);
- * var http = injector.get(Http);
- * http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));
- * ```
- *
- * @deprecated use \@angular/common/http instead
- */
- var Http = /** @class */ (function () {
- function Http(_backend, _defaultOptions) {
- this._backend = _backend;
- this._defaultOptions = _defaultOptions;
- }
- /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {@link BaseRequestOptions} before performing the request.
- */
- /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {\@link BaseRequestOptions} before performing the request.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.request = /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {\@link BaseRequestOptions} before performing the request.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- var /** @type {?} */ responseObservable;
- if (typeof url === 'string') {
- responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url))));
- }
- else if (url instanceof Request) {
- responseObservable = httpRequest(this._backend, url);
- }
- else {
- throw new Error('First argument must be a url string or Request instance.');
- }
- return responseObservable;
- };
- /**
- * Performs a request with `get` http method.
- */
- /**
- * Performs a request with `get` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.get = /**
- * Performs a request with `get` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
- };
- /**
- * Performs a request with `post` http method.
- */
- /**
- * Performs a request with `post` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.post = /**
- * Performs a request with `post` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- function (url, body, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Post, url)));
- };
- /**
- * Performs a request with `put` http method.
- */
- /**
- * Performs a request with `put` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.put = /**
- * Performs a request with `put` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- function (url, body, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Put, url)));
- };
- /**
- * Performs a request with `delete` http method.
- */
- /**
- * Performs a request with `delete` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.delete = /**
- * Performs a request with `delete` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));
- };
- /**
- * Performs a request with `patch` http method.
- */
- /**
- * Performs a request with `patch` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.patch = /**
- * Performs a request with `patch` http method.
- * @param {?} url
- * @param {?} body
- * @param {?=} options
- * @return {?}
- */
- function (url, body, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Patch, url)));
- };
- /**
- * Performs a request with `head` http method.
- */
- /**
- * Performs a request with `head` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.head = /**
- * Performs a request with `head` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
- };
- /**
- * Performs a request with `options` http method.
- */
- /**
- * Performs a request with `options` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Http.prototype.options = /**
- * Performs a request with `options` http method.
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));
- };
- Http.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- Http.ctorParameters = function () { return [
- { type: ConnectionBackend, },
- { type: RequestOptions, },
- ]; };
- return Http;
- }());
- /**
- * @deprecated use \@angular/common/http instead
- */
- var Jsonp = /** @class */ (function (_super) {
- __extends(Jsonp, _super);
- function Jsonp(backend, defaultOptions) {
- return _super.call(this, backend, defaultOptions) || this;
- }
- /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {@link BaseRequestOptions} before performing the request.
- *
- * @security Regular XHR is the safest alternative to JSONP for most applications, and is
- * supported by all current browsers. Because JSONP creates a `<script>` element with
- * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
- * source could expose your application to XSS risks. Data exposed by JSONP may also be
- * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
- * future security issues (e.g. content sniffing). For more detail, see the
- * [Security Guide](http://g.co/ng/security).
- */
- /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {\@link BaseRequestOptions} before performing the request.
- *
- * \@security Regular XHR is the safest alternative to JSONP for most applications, and is
- * supported by all current browsers. Because JSONP creates a `<script>` element with
- * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
- * source could expose your application to XSS risks. Data exposed by JSONP may also be
- * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
- * future security issues (e.g. content sniffing). For more detail, see the
- * [Security Guide](http://g.co/ng/security).
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- Jsonp.prototype.request = /**
- * Performs any type of http request. First argument is required, and can either be a url or
- * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
- * object can be provided as the 2nd argument. The options object will be merged with the values
- * of {\@link BaseRequestOptions} before performing the request.
- *
- * \@security Regular XHR is the safest alternative to JSONP for most applications, and is
- * supported by all current browsers. Because JSONP creates a `<script>` element with
- * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
- * source could expose your application to XSS risks. Data exposed by JSONP may also be
- * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
- * future security issues (e.g. content sniffing). For more detail, see the
- * [Security Guide](http://g.co/ng/security).
- * @param {?} url
- * @param {?=} options
- * @return {?}
- */
- function (url, options) {
- var /** @type {?} */ responseObservable;
- if (typeof url === 'string') {
- url =
- new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url)));
- }
- if (url instanceof Request) {
- if (url.method !== RequestMethod.Get) {
- throw new Error('JSONP requests must use GET request method.');
- }
- responseObservable = httpRequest(this._backend, url);
- }
- else {
- throw new Error('First argument must be a url string or Request instance.');
- }
- return responseObservable;
- };
- Jsonp.decorators = [
- { type: _angular_core.Injectable },
- ];
- /** @nocollapse */
- Jsonp.ctorParameters = function () { return [
- { type: ConnectionBackend, },
- { type: RequestOptions, },
- ]; };
- return Jsonp;
- }(Http));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @return {?}
- */
- function _createDefaultCookieXSRFStrategy() {
- return new CookieXSRFStrategy();
- }
- /**
- * @param {?} xhrBackend
- * @param {?} requestOptions
- * @return {?}
- */
- function httpFactory(xhrBackend, requestOptions) {
- return new Http(xhrBackend, requestOptions);
- }
- /**
- * @param {?} jsonpBackend
- * @param {?} requestOptions
- * @return {?}
- */
- function jsonpFactory(jsonpBackend, requestOptions) {
- return new Jsonp(jsonpBackend, requestOptions);
- }
- /**
- * The module that includes http's providers
- *
- * @deprecated use \@angular/common/http instead
- */
- var HttpModule = /** @class */ (function () {
- function HttpModule() {
- }
- HttpModule.decorators = [
- { type: _angular_core.NgModule, args: [{
- providers: [
- // TODO(pascal): use factory type annotations once supported in DI
- // issue: https://github.com/angular/angular/issues/3183
- { provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions] },
- BrowserXhr,
- { provide: RequestOptions, useClass: BaseRequestOptions },
- { provide: ResponseOptions, useClass: BaseResponseOptions },
- XHRBackend,
- { provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy },
- ],
- },] },
- ];
- /** @nocollapse */
- HttpModule.ctorParameters = function () { return []; };
- return HttpModule;
- }());
- /**
- * The module that includes jsonp's providers
- *
- * @deprecated use \@angular/common/http instead
- */
- var JsonpModule = /** @class */ (function () {
- function JsonpModule() {
- }
- JsonpModule.decorators = [
- { type: _angular_core.NgModule, args: [{
- providers: [
- // TODO(pascal): use factory type annotations once supported in DI
- // issue: https://github.com/angular/angular/issues/3183
- { provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions] },
- BrowserJsonp,
- { provide: RequestOptions, useClass: BaseRequestOptions },
- { provide: ResponseOptions, useClass: BaseResponseOptions },
- JSONPBackend,
- ],
- },] },
- ];
- /** @nocollapse */
- JsonpModule.ctorParameters = function () { return []; };
- return JsonpModule;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @deprecated use \@angular/common/http instead
- */
- var VERSION = new _angular_core.Version('5.2.11');
-
- exports.BrowserXhr = BrowserXhr;
- exports.JSONPBackend = JSONPBackend;
- exports.JSONPConnection = JSONPConnection;
- exports.CookieXSRFStrategy = CookieXSRFStrategy;
- exports.XHRBackend = XHRBackend;
- exports.XHRConnection = XHRConnection;
- exports.BaseRequestOptions = BaseRequestOptions;
- exports.RequestOptions = RequestOptions;
- exports.BaseResponseOptions = BaseResponseOptions;
- exports.ResponseOptions = ResponseOptions;
- exports.ReadyState = ReadyState;
- exports.RequestMethod = RequestMethod;
- exports.ResponseContentType = ResponseContentType;
- exports.ResponseType = ResponseType;
- exports.Headers = Headers;
- exports.Http = Http;
- exports.Jsonp = Jsonp;
- exports.HttpModule = HttpModule;
- exports.JsonpModule = JsonpModule;
- exports.Connection = Connection;
- exports.ConnectionBackend = ConnectionBackend;
- exports.XSRFStrategy = XSRFStrategy;
- exports.Request = Request;
- exports.Response = Response;
- exports.QueryEncoder = QueryEncoder;
- exports.URLSearchParams = URLSearchParams;
- exports.VERSION = VERSION;
- exports.ɵe = BrowserJsonp;
- exports.ɵf = Body;
- exports.ɵa = _createDefaultCookieXSRFStrategy;
- exports.ɵb = httpFactory;
- exports.ɵc = jsonpFactory;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
- //# sourceMappingURL=http.umd.js.map
|