Front end of the Slack clone application.

http.umd.js 93KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Observable'), require('@angular/platform-browser')) :
  8. typeof define === 'function' && define.amd ? define('@angular/http', ['exports', '@angular/core', 'rxjs/Observable', '@angular/platform-browser'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.http = {}),global.ng.core,global.Rx,global.ng.platformBrowser));
  10. }(this, (function (exports,_angular_core,rxjs_Observable,_angular_platformBrowser) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = Object.setPrototypeOf ||
  25. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. /**
  33. * @license Angular v5.2.11
  34. * (c) 2010-2018 Google, Inc. https://angular.io/
  35. * License: MIT
  36. */
  37. /**
  38. * @fileoverview added by tsickle
  39. * @suppress {checkTypes} checked by tsc
  40. */
  41. /**
  42. * @license
  43. * Copyright Google Inc. All Rights Reserved.
  44. *
  45. * Use of this source code is governed by an MIT-style license that can be
  46. * found in the LICENSE file at https://angular.io/license
  47. */
  48. /**
  49. * A backend for http that uses the `XMLHttpRequest` browser API.
  50. *
  51. * Take care not to evaluate this in non-browser contexts.
  52. *
  53. * @deprecated use \@angular/common/http instead
  54. */
  55. var BrowserXhr = /** @class */ (function () {
  56. function BrowserXhr() {
  57. }
  58. /**
  59. * @return {?}
  60. */
  61. BrowserXhr.prototype.build = /**
  62. * @return {?}
  63. */
  64. function () { return /** @type {?} */ ((new XMLHttpRequest())); };
  65. BrowserXhr.decorators = [
  66. { type: _angular_core.Injectable },
  67. ];
  68. /** @nocollapse */
  69. BrowserXhr.ctorParameters = function () { return []; };
  70. return BrowserXhr;
  71. }());
  72. /**
  73. * @fileoverview added by tsickle
  74. * @suppress {checkTypes} checked by tsc
  75. */
  76. /**
  77. * @license
  78. * Copyright Google Inc. All Rights Reserved.
  79. *
  80. * Use of this source code is governed by an MIT-style license that can be
  81. * found in the LICENSE file at https://angular.io/license
  82. */
  83. /** @enum {number} */
  84. var RequestMethod = {
  85. Get: 0,
  86. Post: 1,
  87. Put: 2,
  88. Delete: 3,
  89. Options: 4,
  90. Head: 5,
  91. Patch: 6,
  92. };
  93. RequestMethod[RequestMethod.Get] = "Get";
  94. RequestMethod[RequestMethod.Post] = "Post";
  95. RequestMethod[RequestMethod.Put] = "Put";
  96. RequestMethod[RequestMethod.Delete] = "Delete";
  97. RequestMethod[RequestMethod.Options] = "Options";
  98. RequestMethod[RequestMethod.Head] = "Head";
  99. RequestMethod[RequestMethod.Patch] = "Patch";
  100. /** @enum {number} */
  101. var ReadyState = {
  102. Unsent: 0,
  103. Open: 1,
  104. HeadersReceived: 2,
  105. Loading: 3,
  106. Done: 4,
  107. Cancelled: 5,
  108. };
  109. ReadyState[ReadyState.Unsent] = "Unsent";
  110. ReadyState[ReadyState.Open] = "Open";
  111. ReadyState[ReadyState.HeadersReceived] = "HeadersReceived";
  112. ReadyState[ReadyState.Loading] = "Loading";
  113. ReadyState[ReadyState.Done] = "Done";
  114. ReadyState[ReadyState.Cancelled] = "Cancelled";
  115. /** @enum {number} */
  116. var ResponseType = {
  117. Basic: 0,
  118. Cors: 1,
  119. Default: 2,
  120. Error: 3,
  121. Opaque: 4,
  122. };
  123. ResponseType[ResponseType.Basic] = "Basic";
  124. ResponseType[ResponseType.Cors] = "Cors";
  125. ResponseType[ResponseType.Default] = "Default";
  126. ResponseType[ResponseType.Error] = "Error";
  127. ResponseType[ResponseType.Opaque] = "Opaque";
  128. /** @enum {number} */
  129. var ContentType = {
  130. NONE: 0,
  131. JSON: 1,
  132. FORM: 2,
  133. FORM_DATA: 3,
  134. TEXT: 4,
  135. BLOB: 5,
  136. ARRAY_BUFFER: 6,
  137. };
  138. ContentType[ContentType.NONE] = "NONE";
  139. ContentType[ContentType.JSON] = "JSON";
  140. ContentType[ContentType.FORM] = "FORM";
  141. ContentType[ContentType.FORM_DATA] = "FORM_DATA";
  142. ContentType[ContentType.TEXT] = "TEXT";
  143. ContentType[ContentType.BLOB] = "BLOB";
  144. ContentType[ContentType.ARRAY_BUFFER] = "ARRAY_BUFFER";
  145. /** @enum {number} */
  146. var ResponseContentType = {
  147. Text: 0,
  148. Json: 1,
  149. ArrayBuffer: 2,
  150. Blob: 3,
  151. };
  152. ResponseContentType[ResponseContentType.Text] = "Text";
  153. ResponseContentType[ResponseContentType.Json] = "Json";
  154. ResponseContentType[ResponseContentType.ArrayBuffer] = "ArrayBuffer";
  155. ResponseContentType[ResponseContentType.Blob] = "Blob";
  156. /**
  157. * @fileoverview added by tsickle
  158. * @suppress {checkTypes} checked by tsc
  159. */
  160. /**
  161. * @license
  162. * Copyright Google Inc. All Rights Reserved.
  163. *
  164. * Use of this source code is governed by an MIT-style license that can be
  165. * found in the LICENSE file at https://angular.io/license
  166. */
  167. /**
  168. * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
  169. * specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).
  170. *
  171. * The only known difference between this `Headers` implementation and the spec is the
  172. * lack of an `entries` method.
  173. *
  174. * ### Example
  175. *
  176. * ```
  177. * import {Headers} from '\@angular/http';
  178. *
  179. * var firstHeaders = new Headers();
  180. * firstHeaders.append('Content-Type', 'image/jpeg');
  181. * console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
  182. *
  183. * // Create headers from Plain Old JavaScript Object
  184. * var secondHeaders = new Headers({
  185. * 'X-My-Custom-Header': 'Angular'
  186. * });
  187. * console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
  188. *
  189. * var thirdHeaders = new Headers(secondHeaders);
  190. * console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'
  191. * ```
  192. *
  193. * @deprecated use \@angular/common/http instead
  194. */
  195. var Headers = /** @class */ (function () {
  196. // TODO(vicb): any -> string|string[]
  197. function Headers(headers) {
  198. var _this = this;
  199. /**
  200. * \@internal header names are lower case
  201. */
  202. this._headers = new Map();
  203. /**
  204. * \@internal map lower case names to actual names
  205. */
  206. this._normalizedNames = new Map();
  207. if (!headers) {
  208. return;
  209. }
  210. if (headers instanceof Headers) {
  211. headers.forEach(function (values, name) {
  212. values.forEach(function (value) { return _this.append(name, value); });
  213. });
  214. return;
  215. }
  216. Object.keys(headers).forEach(function (name) {
  217. var /** @type {?} */ values = Array.isArray(headers[name]) ? headers[name] : [headers[name]];
  218. _this.delete(name);
  219. values.forEach(function (value) { return _this.append(name, value); });
  220. });
  221. }
  222. /**
  223. * Returns a new Headers instance from the given DOMString of Response Headers
  224. */
  225. /**
  226. * Returns a new Headers instance from the given DOMString of Response Headers
  227. * @param {?} headersString
  228. * @return {?}
  229. */
  230. Headers.fromResponseHeaderString = /**
  231. * Returns a new Headers instance from the given DOMString of Response Headers
  232. * @param {?} headersString
  233. * @return {?}
  234. */
  235. function (headersString) {
  236. var /** @type {?} */ headers = new Headers();
  237. headersString.split('\n').forEach(function (line) {
  238. var /** @type {?} */ index = line.indexOf(':');
  239. if (index > 0) {
  240. var /** @type {?} */ name_1 = line.slice(0, index);
  241. var /** @type {?} */ value = line.slice(index + 1).trim();
  242. headers.set(name_1, value);
  243. }
  244. });
  245. return headers;
  246. };
  247. /**
  248. * Appends a header to existing list of header values for a given header name.
  249. */
  250. /**
  251. * Appends a header to existing list of header values for a given header name.
  252. * @param {?} name
  253. * @param {?} value
  254. * @return {?}
  255. */
  256. Headers.prototype.append = /**
  257. * Appends a header to existing list of header values for a given header name.
  258. * @param {?} name
  259. * @param {?} value
  260. * @return {?}
  261. */
  262. function (name, value) {
  263. var /** @type {?} */ values = this.getAll(name);
  264. if (values === null) {
  265. this.set(name, value);
  266. }
  267. else {
  268. values.push(value);
  269. }
  270. };
  271. /**
  272. * Deletes all header values for the given name.
  273. */
  274. /**
  275. * Deletes all header values for the given name.
  276. * @param {?} name
  277. * @return {?}
  278. */
  279. Headers.prototype.delete = /**
  280. * Deletes all header values for the given name.
  281. * @param {?} name
  282. * @return {?}
  283. */
  284. function (name) {
  285. var /** @type {?} */ lcName = name.toLowerCase();
  286. this._normalizedNames.delete(lcName);
  287. this._headers.delete(lcName);
  288. };
  289. /**
  290. * @param {?} fn
  291. * @return {?}
  292. */
  293. Headers.prototype.forEach = /**
  294. * @param {?} fn
  295. * @return {?}
  296. */
  297. function (fn) {
  298. var _this = this;
  299. this._headers.forEach(function (values, lcName) { return fn(values, _this._normalizedNames.get(lcName), _this._headers); });
  300. };
  301. /**
  302. * Returns first header that matches given name.
  303. */
  304. /**
  305. * Returns first header that matches given name.
  306. * @param {?} name
  307. * @return {?}
  308. */
  309. Headers.prototype.get = /**
  310. * Returns first header that matches given name.
  311. * @param {?} name
  312. * @return {?}
  313. */
  314. function (name) {
  315. var /** @type {?} */ values = this.getAll(name);
  316. if (values === null) {
  317. return null;
  318. }
  319. return values.length > 0 ? values[0] : null;
  320. };
  321. /**
  322. * Checks for existence of header by given name.
  323. */
  324. /**
  325. * Checks for existence of header by given name.
  326. * @param {?} name
  327. * @return {?}
  328. */
  329. Headers.prototype.has = /**
  330. * Checks for existence of header by given name.
  331. * @param {?} name
  332. * @return {?}
  333. */
  334. function (name) { return this._headers.has(name.toLowerCase()); };
  335. /**
  336. * Returns the names of the headers
  337. */
  338. /**
  339. * Returns the names of the headers
  340. * @return {?}
  341. */
  342. Headers.prototype.keys = /**
  343. * Returns the names of the headers
  344. * @return {?}
  345. */
  346. function () { return Array.from(this._normalizedNames.values()); };
  347. /**
  348. * Sets or overrides header value for given name.
  349. */
  350. /**
  351. * Sets or overrides header value for given name.
  352. * @param {?} name
  353. * @param {?} value
  354. * @return {?}
  355. */
  356. Headers.prototype.set = /**
  357. * Sets or overrides header value for given name.
  358. * @param {?} name
  359. * @param {?} value
  360. * @return {?}
  361. */
  362. function (name, value) {
  363. if (Array.isArray(value)) {
  364. if (value.length) {
  365. this._headers.set(name.toLowerCase(), [value.join(',')]);
  366. }
  367. }
  368. else {
  369. this._headers.set(name.toLowerCase(), [value]);
  370. }
  371. this.mayBeSetNormalizedName(name);
  372. };
  373. /**
  374. * Returns values of all headers.
  375. */
  376. /**
  377. * Returns values of all headers.
  378. * @return {?}
  379. */
  380. Headers.prototype.values = /**
  381. * Returns values of all headers.
  382. * @return {?}
  383. */
  384. function () { return Array.from(this._headers.values()); };
  385. /**
  386. * Returns string of all headers.
  387. */
  388. // TODO(vicb): returns {[name: string]: string[]}
  389. /**
  390. * Returns string of all headers.
  391. * @return {?}
  392. */
  393. Headers.prototype.toJSON = /**
  394. * Returns string of all headers.
  395. * @return {?}
  396. */
  397. function () {
  398. var _this = this;
  399. var /** @type {?} */ serialized = {};
  400. this._headers.forEach(function (values, name) {
  401. var /** @type {?} */ split = [];
  402. values.forEach(function (v) { return split.push.apply(split, v.split(',')); });
  403. serialized[/** @type {?} */ ((_this._normalizedNames.get(name)))] = split;
  404. });
  405. return serialized;
  406. };
  407. /**
  408. * Returns list of header values for a given name.
  409. */
  410. /**
  411. * Returns list of header values for a given name.
  412. * @param {?} name
  413. * @return {?}
  414. */
  415. Headers.prototype.getAll = /**
  416. * Returns list of header values for a given name.
  417. * @param {?} name
  418. * @return {?}
  419. */
  420. function (name) {
  421. return this.has(name) ? this._headers.get(name.toLowerCase()) || null : null;
  422. };
  423. /**
  424. * This method is not implemented.
  425. */
  426. /**
  427. * This method is not implemented.
  428. * @return {?}
  429. */
  430. Headers.prototype.entries = /**
  431. * This method is not implemented.
  432. * @return {?}
  433. */
  434. function () { throw new Error('"entries" method is not implemented on Headers class'); };
  435. /**
  436. * @param {?} name
  437. * @return {?}
  438. */
  439. Headers.prototype.mayBeSetNormalizedName = /**
  440. * @param {?} name
  441. * @return {?}
  442. */
  443. function (name) {
  444. var /** @type {?} */ lcName = name.toLowerCase();
  445. if (!this._normalizedNames.has(lcName)) {
  446. this._normalizedNames.set(lcName, name);
  447. }
  448. };
  449. return Headers;
  450. }());
  451. /**
  452. * @fileoverview added by tsickle
  453. * @suppress {checkTypes} checked by tsc
  454. */
  455. /**
  456. * @license
  457. * Copyright Google Inc. All Rights Reserved.
  458. *
  459. * Use of this source code is governed by an MIT-style license that can be
  460. * found in the LICENSE file at https://angular.io/license
  461. */
  462. /**
  463. * Creates a response options object to be optionally provided when instantiating a
  464. * {\@link Response}.
  465. *
  466. * This class is based on the `ResponseInit` description in the [Fetch
  467. * Spec](https://fetch.spec.whatwg.org/#responseinit).
  468. *
  469. * All values are null by default. Typical defaults can be found in the
  470. * {\@link BaseResponseOptions} class, which sub-classes `ResponseOptions`.
  471. *
  472. * This class may be used in tests to build {\@link Response Responses} for
  473. * mock responses (see {\@link MockBackend}).
  474. *
  475. * ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview))
  476. *
  477. * ```typescript
  478. * import {ResponseOptions, Response} from '\@angular/http';
  479. *
  480. * var options = new ResponseOptions({
  481. * body: '{"name":"Jeff"}'
  482. * });
  483. * var res = new Response(options);
  484. *
  485. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  486. * ```
  487. *
  488. * @deprecated use \@angular/common/http instead
  489. */
  490. var ResponseOptions = /** @class */ (function () {
  491. function ResponseOptions(opts) {
  492. if (opts === void 0) { opts = {}; }
  493. var body = opts.body, status = opts.status, headers = opts.headers, statusText = opts.statusText, type = opts.type, url = opts.url;
  494. this.body = body != null ? body : null;
  495. this.status = status != null ? status : null;
  496. this.headers = headers != null ? headers : null;
  497. this.statusText = statusText != null ? statusText : null;
  498. this.type = type != null ? type : null;
  499. this.url = url != null ? url : null;
  500. }
  501. /**
  502. * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
  503. * override
  504. * existing values. This method will not change the values of the instance on which it is being
  505. * called.
  506. *
  507. * This may be useful when sharing a base `ResponseOptions` object inside tests,
  508. * where certain properties may change from test to test.
  509. *
  510. * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
  511. *
  512. * ```typescript
  513. * import {ResponseOptions, Response} from '@angular/http';
  514. *
  515. * var options = new ResponseOptions({
  516. * body: {name: 'Jeff'}
  517. * });
  518. * var res = new Response(options.merge({
  519. * url: 'https://google.com'
  520. * }));
  521. * console.log('options.url:', options.url); // null
  522. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  523. * console.log('res.url:', res.url); // https://google.com
  524. * ```
  525. */
  526. /**
  527. * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
  528. * override
  529. * existing values. This method will not change the values of the instance on which it is being
  530. * called.
  531. *
  532. * This may be useful when sharing a base `ResponseOptions` object inside tests,
  533. * where certain properties may change from test to test.
  534. *
  535. * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
  536. *
  537. * ```typescript
  538. * import {ResponseOptions, Response} from '\@angular/http';
  539. *
  540. * var options = new ResponseOptions({
  541. * body: {name: 'Jeff'}
  542. * });
  543. * var res = new Response(options.merge({
  544. * url: 'https://google.com'
  545. * }));
  546. * console.log('options.url:', options.url); // null
  547. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  548. * console.log('res.url:', res.url); // https://google.com
  549. * ```
  550. * @param {?=} options
  551. * @return {?}
  552. */
  553. ResponseOptions.prototype.merge = /**
  554. * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
  555. * override
  556. * existing values. This method will not change the values of the instance on which it is being
  557. * called.
  558. *
  559. * This may be useful when sharing a base `ResponseOptions` object inside tests,
  560. * where certain properties may change from test to test.
  561. *
  562. * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
  563. *
  564. * ```typescript
  565. * import {ResponseOptions, Response} from '\@angular/http';
  566. *
  567. * var options = new ResponseOptions({
  568. * body: {name: 'Jeff'}
  569. * });
  570. * var res = new Response(options.merge({
  571. * url: 'https://google.com'
  572. * }));
  573. * console.log('options.url:', options.url); // null
  574. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  575. * console.log('res.url:', res.url); // https://google.com
  576. * ```
  577. * @param {?=} options
  578. * @return {?}
  579. */
  580. function (options) {
  581. return new ResponseOptions({
  582. body: options && options.body != null ? options.body : this.body,
  583. status: options && options.status != null ? options.status : this.status,
  584. headers: options && options.headers != null ? options.headers : this.headers,
  585. statusText: options && options.statusText != null ? options.statusText : this.statusText,
  586. type: options && options.type != null ? options.type : this.type,
  587. url: options && options.url != null ? options.url : this.url,
  588. });
  589. };
  590. return ResponseOptions;
  591. }());
  592. /**
  593. * Subclass of {\@link ResponseOptions}, with default values.
  594. *
  595. * Default values:
  596. * * status: 200
  597. * * headers: empty {\@link Headers} object
  598. *
  599. * This class could be extended and bound to the {\@link ResponseOptions} class
  600. * when configuring an {\@link Injector}, in order to override the default options
  601. * used by {\@link Http} to create {\@link Response Responses}.
  602. *
  603. * ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview))
  604. *
  605. * ```typescript
  606. * import {provide} from '\@angular/core';
  607. * import {bootstrap} from '\@angular/platform-browser/browser';
  608. * import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
  609. * '\@angular/http';
  610. * import {App} from './myapp';
  611. *
  612. * class MyOptions extends BaseResponseOptions {
  613. * headers:Headers = new Headers({network: 'github'});
  614. * }
  615. *
  616. * bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]);
  617. * ```
  618. *
  619. * The options could also be extended when manually creating a {\@link Response}
  620. * object.
  621. *
  622. * ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview))
  623. *
  624. * ```
  625. * import {BaseResponseOptions, Response} from '\@angular/http';
  626. *
  627. * var options = new BaseResponseOptions();
  628. * var res = new Response(options.merge({
  629. * body: 'Angular',
  630. * headers: new Headers({framework: 'angular'})
  631. * }));
  632. * console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
  633. * console.log('res.text():', res.text()); // Angular;
  634. * ```
  635. *
  636. * @deprecated use \@angular/common/http instead
  637. */
  638. var BaseResponseOptions = /** @class */ (function (_super) {
  639. __extends(BaseResponseOptions, _super);
  640. function BaseResponseOptions() {
  641. return _super.call(this, { status: 200, statusText: 'Ok', type: ResponseType.Default, headers: new Headers() }) || this;
  642. }
  643. BaseResponseOptions.decorators = [
  644. { type: _angular_core.Injectable },
  645. ];
  646. /** @nocollapse */
  647. BaseResponseOptions.ctorParameters = function () { return []; };
  648. return BaseResponseOptions;
  649. }(ResponseOptions));
  650. /**
  651. * @fileoverview added by tsickle
  652. * @suppress {checkTypes} checked by tsc
  653. */
  654. /**
  655. * @license
  656. * Copyright Google Inc. All Rights Reserved.
  657. *
  658. * Use of this source code is governed by an MIT-style license that can be
  659. * found in the LICENSE file at https://angular.io/license
  660. */
  661. /**
  662. * Abstract class from which real backends are derived.
  663. *
  664. * The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
  665. * {\@link Request}.
  666. *
  667. * @deprecated use \@angular/common/http instead
  668. * @abstract
  669. */
  670. var ConnectionBackend = /** @class */ (function () {
  671. function ConnectionBackend() {
  672. }
  673. return ConnectionBackend;
  674. }());
  675. /**
  676. * Abstract class from which real connections are derived.
  677. *
  678. * @deprecated use \@angular/common/http instead
  679. * @abstract
  680. */
  681. var Connection = /** @class */ (function () {
  682. function Connection() {
  683. }
  684. return Connection;
  685. }());
  686. /**
  687. * An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.
  688. *
  689. * @deprecated use \@angular/common/http instead
  690. * @abstract
  691. */
  692. var XSRFStrategy = /** @class */ (function () {
  693. function XSRFStrategy() {
  694. }
  695. return XSRFStrategy;
  696. }());
  697. /**
  698. * Interface for options to construct a RequestOptions, based on
  699. * [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
  700. *
  701. * @deprecated use \@angular/common/http instead
  702. * @record
  703. */
  704. /**
  705. * Required structure when constructing new Request();
  706. * @record
  707. */
  708. /**
  709. * Interface for options to construct a Response, based on
  710. * [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
  711. *
  712. * @deprecated use \@angular/common/http instead
  713. * @record
  714. */
  715. /**
  716. * @fileoverview added by tsickle
  717. * @suppress {checkTypes} checked by tsc
  718. */
  719. /**
  720. * @license
  721. * Copyright Google Inc. All Rights Reserved.
  722. *
  723. * Use of this source code is governed by an MIT-style license that can be
  724. * found in the LICENSE file at https://angular.io/license
  725. */
  726. /**
  727. * @param {?} method
  728. * @return {?}
  729. */
  730. function normalizeMethodName(method) {
  731. if (typeof method !== 'string')
  732. return method;
  733. switch (method.toUpperCase()) {
  734. case 'GET':
  735. return RequestMethod.Get;
  736. case 'POST':
  737. return RequestMethod.Post;
  738. case 'PUT':
  739. return RequestMethod.Put;
  740. case 'DELETE':
  741. return RequestMethod.Delete;
  742. case 'OPTIONS':
  743. return RequestMethod.Options;
  744. case 'HEAD':
  745. return RequestMethod.Head;
  746. case 'PATCH':
  747. return RequestMethod.Patch;
  748. }
  749. throw new Error("Invalid request method. The method \"" + method + "\" is not supported.");
  750. }
  751. var isSuccess = function (status) { return (status >= 200 && status < 300); };
  752. /**
  753. * @param {?} xhr
  754. * @return {?}
  755. */
  756. function getResponseURL(xhr) {
  757. if ('responseURL' in xhr) {
  758. return xhr.responseURL;
  759. }
  760. if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
  761. return xhr.getResponseHeader('X-Request-URL');
  762. }
  763. return null;
  764. }
  765. /**
  766. * @param {?} input
  767. * @return {?}
  768. */
  769. /**
  770. * @param {?} input
  771. * @return {?}
  772. */
  773. function stringToArrayBuffer(input) {
  774. var /** @type {?} */ view = new Uint16Array(input.length);
  775. for (var /** @type {?} */ i = 0, /** @type {?} */ strLen = input.length; i < strLen; i++) {
  776. view[i] = input.charCodeAt(i);
  777. }
  778. return view.buffer;
  779. }
  780. /**
  781. * @fileoverview added by tsickle
  782. * @suppress {checkTypes} checked by tsc
  783. */
  784. /**
  785. * @license
  786. * Copyright Google Inc. All Rights Reserved.
  787. *
  788. * Use of this source code is governed by an MIT-style license that can be
  789. * found in the LICENSE file at https://angular.io/license
  790. */
  791. /**
  792. * @param {?=} rawParams
  793. * @return {?}
  794. */
  795. function paramParser(rawParams) {
  796. if (rawParams === void 0) { rawParams = ''; }
  797. var /** @type {?} */ map = new Map();
  798. if (rawParams.length > 0) {
  799. var /** @type {?} */ params = rawParams.split('&');
  800. params.forEach(function (param) {
  801. var /** @type {?} */ eqIdx = param.indexOf('=');
  802. var _a = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)], key = _a[0], val = _a[1];
  803. var /** @type {?} */ list = map.get(key) || [];
  804. list.push(val);
  805. map.set(key, list);
  806. });
  807. }
  808. return map;
  809. }
  810. /**
  811. * @deprecated use \@angular/common/http instead
  812. *
  813. */
  814. var QueryEncoder = /** @class */ (function () {
  815. function QueryEncoder() {
  816. }
  817. /**
  818. * @param {?} k
  819. * @return {?}
  820. */
  821. QueryEncoder.prototype.encodeKey = /**
  822. * @param {?} k
  823. * @return {?}
  824. */
  825. function (k) { return standardEncoding(k); };
  826. /**
  827. * @param {?} v
  828. * @return {?}
  829. */
  830. QueryEncoder.prototype.encodeValue = /**
  831. * @param {?} v
  832. * @return {?}
  833. */
  834. function (v) { return standardEncoding(v); };
  835. return QueryEncoder;
  836. }());
  837. /**
  838. * @param {?} v
  839. * @return {?}
  840. */
  841. function standardEncoding(v) {
  842. return encodeURIComponent(v)
  843. .replace(/%40/gi, '@')
  844. .replace(/%3A/gi, ':')
  845. .replace(/%24/gi, '$')
  846. .replace(/%2C/gi, ',')
  847. .replace(/%3B/gi, ';')
  848. .replace(/%2B/gi, '+')
  849. .replace(/%3D/gi, '=')
  850. .replace(/%3F/gi, '?')
  851. .replace(/%2F/gi, '/');
  852. }
  853. /**
  854. * Map-like representation of url search parameters, based on
  855. * [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
  856. * with several extensions for merging URLSearchParams objects:
  857. * - setAll()
  858. * - appendAll()
  859. * - replaceAll()
  860. *
  861. * This class accepts an optional second parameter of ${\@link QueryEncoder},
  862. * which is used to serialize parameters before making a request. By default,
  863. * `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`,
  864. * and then un-encodes certain characters that are allowed to be part of the query
  865. * according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
  866. *
  867. * These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /`
  868. *
  869. * If the set of allowed query characters is not acceptable for a particular backend,
  870. * `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams.
  871. *
  872. * ```
  873. * import {URLSearchParams, QueryEncoder} from '\@angular/http';
  874. * class MyQueryEncoder extends QueryEncoder {
  875. * encodeKey(k: string): string {
  876. * return myEncodingFunction(k);
  877. * }
  878. *
  879. * encodeValue(v: string): string {
  880. * return myEncodingFunction(v);
  881. * }
  882. * }
  883. *
  884. * let params = new URLSearchParams('', new MyQueryEncoder());
  885. * ```
  886. * @deprecated use \@angular/common/http instead
  887. */
  888. var URLSearchParams = /** @class */ (function () {
  889. function URLSearchParams(rawParams, queryEncoder) {
  890. if (rawParams === void 0) { rawParams = ''; }
  891. if (queryEncoder === void 0) { queryEncoder = new QueryEncoder(); }
  892. this.rawParams = rawParams;
  893. this.queryEncoder = queryEncoder;
  894. this.paramsMap = paramParser(rawParams);
  895. }
  896. /**
  897. * @return {?}
  898. */
  899. URLSearchParams.prototype.clone = /**
  900. * @return {?}
  901. */
  902. function () {
  903. var /** @type {?} */ clone = new URLSearchParams('', this.queryEncoder);
  904. clone.appendAll(this);
  905. return clone;
  906. };
  907. /**
  908. * @param {?} param
  909. * @return {?}
  910. */
  911. URLSearchParams.prototype.has = /**
  912. * @param {?} param
  913. * @return {?}
  914. */
  915. function (param) { return this.paramsMap.has(param); };
  916. /**
  917. * @param {?} param
  918. * @return {?}
  919. */
  920. URLSearchParams.prototype.get = /**
  921. * @param {?} param
  922. * @return {?}
  923. */
  924. function (param) {
  925. var /** @type {?} */ storedParam = this.paramsMap.get(param);
  926. return Array.isArray(storedParam) ? storedParam[0] : null;
  927. };
  928. /**
  929. * @param {?} param
  930. * @return {?}
  931. */
  932. URLSearchParams.prototype.getAll = /**
  933. * @param {?} param
  934. * @return {?}
  935. */
  936. function (param) { return this.paramsMap.get(param) || []; };
  937. /**
  938. * @param {?} param
  939. * @param {?} val
  940. * @return {?}
  941. */
  942. URLSearchParams.prototype.set = /**
  943. * @param {?} param
  944. * @param {?} val
  945. * @return {?}
  946. */
  947. function (param, val) {
  948. if (val === void 0 || val === null) {
  949. this.delete(param);
  950. return;
  951. }
  952. var /** @type {?} */ list = this.paramsMap.get(param) || [];
  953. list.length = 0;
  954. list.push(val);
  955. this.paramsMap.set(param, list);
  956. };
  957. // A merge operation
  958. // For each name-values pair in `searchParams`, perform `set(name, values[0])`
  959. //
  960. // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4], c=[8], b=[7]"
  961. //
  962. // TODO(@caitp): document this better
  963. /**
  964. * @param {?} searchParams
  965. * @return {?}
  966. */
  967. URLSearchParams.prototype.setAll = /**
  968. * @param {?} searchParams
  969. * @return {?}
  970. */
  971. function (searchParams) {
  972. var _this = this;
  973. searchParams.paramsMap.forEach(function (value, param) {
  974. var /** @type {?} */ list = _this.paramsMap.get(param) || [];
  975. list.length = 0;
  976. list.push(value[0]);
  977. _this.paramsMap.set(param, list);
  978. });
  979. };
  980. /**
  981. * @param {?} param
  982. * @param {?} val
  983. * @return {?}
  984. */
  985. URLSearchParams.prototype.append = /**
  986. * @param {?} param
  987. * @param {?} val
  988. * @return {?}
  989. */
  990. function (param, val) {
  991. if (val === void 0 || val === null)
  992. return;
  993. var /** @type {?} */ list = this.paramsMap.get(param) || [];
  994. list.push(val);
  995. this.paramsMap.set(param, list);
  996. };
  997. // A merge operation
  998. // For each name-values pair in `searchParams`, perform `append(name, value)`
  999. // for each value in `values`.
  1000. //
  1001. // E.g: "a=[1,2], c=[8]" + "a=[3,4], b=[7]" = "a=[1,2,3,4], c=[8], b=[7]"
  1002. //
  1003. // TODO(@caitp): document this better
  1004. /**
  1005. * @param {?} searchParams
  1006. * @return {?}
  1007. */
  1008. URLSearchParams.prototype.appendAll = /**
  1009. * @param {?} searchParams
  1010. * @return {?}
  1011. */
  1012. function (searchParams) {
  1013. var _this = this;
  1014. searchParams.paramsMap.forEach(function (value, param) {
  1015. var /** @type {?} */ list = _this.paramsMap.get(param) || [];
  1016. for (var /** @type {?} */ i = 0; i < value.length; ++i) {
  1017. list.push(value[i]);
  1018. }
  1019. _this.paramsMap.set(param, list);
  1020. });
  1021. };
  1022. // A merge operation
  1023. // For each name-values pair in `searchParams`, perform `delete(name)`,
  1024. // followed by `set(name, values)`
  1025. //
  1026. // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4,5,6], c=[8], b=[7]"
  1027. //
  1028. // TODO(@caitp): document this better
  1029. /**
  1030. * @param {?} searchParams
  1031. * @return {?}
  1032. */
  1033. URLSearchParams.prototype.replaceAll = /**
  1034. * @param {?} searchParams
  1035. * @return {?}
  1036. */
  1037. function (searchParams) {
  1038. var _this = this;
  1039. searchParams.paramsMap.forEach(function (value, param) {
  1040. var /** @type {?} */ list = _this.paramsMap.get(param) || [];
  1041. list.length = 0;
  1042. for (var /** @type {?} */ i = 0; i < value.length; ++i) {
  1043. list.push(value[i]);
  1044. }
  1045. _this.paramsMap.set(param, list);
  1046. });
  1047. };
  1048. /**
  1049. * @return {?}
  1050. */
  1051. URLSearchParams.prototype.toString = /**
  1052. * @return {?}
  1053. */
  1054. function () {
  1055. var _this = this;
  1056. var /** @type {?} */ paramsList = [];
  1057. this.paramsMap.forEach(function (values, k) {
  1058. values.forEach(function (v) {
  1059. return paramsList.push(_this.queryEncoder.encodeKey(k) + '=' + _this.queryEncoder.encodeValue(v));
  1060. });
  1061. });
  1062. return paramsList.join('&');
  1063. };
  1064. /**
  1065. * @param {?} param
  1066. * @return {?}
  1067. */
  1068. URLSearchParams.prototype.delete = /**
  1069. * @param {?} param
  1070. * @return {?}
  1071. */
  1072. function (param) { this.paramsMap.delete(param); };
  1073. return URLSearchParams;
  1074. }());
  1075. /**
  1076. * @fileoverview added by tsickle
  1077. * @suppress {checkTypes} checked by tsc
  1078. */
  1079. /**
  1080. * @license
  1081. * Copyright Google Inc. All Rights Reserved.
  1082. *
  1083. * Use of this source code is governed by an MIT-style license that can be
  1084. * found in the LICENSE file at https://angular.io/license
  1085. */
  1086. /**
  1087. * HTTP request body used by both {\@link Request} and {\@link Response}
  1088. * https://fetch.spec.whatwg.org/#body
  1089. * @abstract
  1090. */
  1091. var Body = /** @class */ (function () {
  1092. function Body() {
  1093. }
  1094. /**
  1095. * Attempts to return body as parsed `JSON` object, or raises an exception.
  1096. */
  1097. /**
  1098. * Attempts to return body as parsed `JSON` object, or raises an exception.
  1099. * @return {?}
  1100. */
  1101. Body.prototype.json = /**
  1102. * Attempts to return body as parsed `JSON` object, or raises an exception.
  1103. * @return {?}
  1104. */
  1105. function () {
  1106. if (typeof this._body === 'string') {
  1107. return JSON.parse(/** @type {?} */ (this._body));
  1108. }
  1109. if (this._body instanceof ArrayBuffer) {
  1110. return JSON.parse(this.text());
  1111. }
  1112. return this._body;
  1113. };
  1114. /**
  1115. * Returns the body as a string, presuming `toString()` can be called on the response body.
  1116. *
  1117. * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
  1118. * bytes in the buffer will be interpreted. Valid values are:
  1119. *
  1120. * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
  1121. * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
  1122. * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
  1123. * into consideration. This is the default behavior to avoid breaking apps, but should be
  1124. * considered deprecated.
  1125. *
  1126. * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
  1127. */
  1128. /**
  1129. * Returns the body as a string, presuming `toString()` can be called on the response body.
  1130. *
  1131. * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
  1132. * bytes in the buffer will be interpreted. Valid values are:
  1133. *
  1134. * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
  1135. * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
  1136. * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
  1137. * into consideration. This is the default behavior to avoid breaking apps, but should be
  1138. * considered deprecated.
  1139. *
  1140. * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
  1141. * @param {?=} encodingHint
  1142. * @return {?}
  1143. */
  1144. Body.prototype.text = /**
  1145. * Returns the body as a string, presuming `toString()` can be called on the response body.
  1146. *
  1147. * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
  1148. * bytes in the buffer will be interpreted. Valid values are:
  1149. *
  1150. * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
  1151. * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
  1152. * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
  1153. * into consideration. This is the default behavior to avoid breaking apps, but should be
  1154. * considered deprecated.
  1155. *
  1156. * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
  1157. * @param {?=} encodingHint
  1158. * @return {?}
  1159. */
  1160. function (encodingHint) {
  1161. if (encodingHint === void 0) { encodingHint = 'legacy'; }
  1162. if (this._body instanceof URLSearchParams) {
  1163. return this._body.toString();
  1164. }
  1165. if (this._body instanceof ArrayBuffer) {
  1166. switch (encodingHint) {
  1167. case 'legacy':
  1168. return String.fromCharCode.apply(null, new Uint16Array(/** @type {?} */ (this._body)));
  1169. case 'iso-8859':
  1170. return String.fromCharCode.apply(null, new Uint8Array(/** @type {?} */ (this._body)));
  1171. default:
  1172. throw new Error("Invalid value for encodingHint: " + encodingHint);
  1173. }
  1174. }
  1175. if (this._body == null) {
  1176. return '';
  1177. }
  1178. if (typeof this._body === 'object') {
  1179. return JSON.stringify(this._body, null, 2);
  1180. }
  1181. return this._body.toString();
  1182. };
  1183. /**
  1184. * Return the body as an ArrayBuffer
  1185. */
  1186. /**
  1187. * Return the body as an ArrayBuffer
  1188. * @return {?}
  1189. */
  1190. Body.prototype.arrayBuffer = /**
  1191. * Return the body as an ArrayBuffer
  1192. * @return {?}
  1193. */
  1194. function () {
  1195. if (this._body instanceof ArrayBuffer) {
  1196. return /** @type {?} */ (this._body);
  1197. }
  1198. return stringToArrayBuffer(this.text());
  1199. };
  1200. /**
  1201. * Returns the request's body as a Blob, assuming that body exists.
  1202. */
  1203. /**
  1204. * Returns the request's body as a Blob, assuming that body exists.
  1205. * @return {?}
  1206. */
  1207. Body.prototype.blob = /**
  1208. * Returns the request's body as a Blob, assuming that body exists.
  1209. * @return {?}
  1210. */
  1211. function () {
  1212. if (this._body instanceof Blob) {
  1213. return /** @type {?} */ (this._body);
  1214. }
  1215. if (this._body instanceof ArrayBuffer) {
  1216. return new Blob([this._body]);
  1217. }
  1218. throw new Error('The request body isn\'t either a blob or an array buffer');
  1219. };
  1220. return Body;
  1221. }());
  1222. /**
  1223. * @fileoverview added by tsickle
  1224. * @suppress {checkTypes} checked by tsc
  1225. */
  1226. /**
  1227. * @license
  1228. * Copyright Google Inc. All Rights Reserved.
  1229. *
  1230. * Use of this source code is governed by an MIT-style license that can be
  1231. * found in the LICENSE file at https://angular.io/license
  1232. */
  1233. /**
  1234. * Creates `Response` instances from provided values.
  1235. *
  1236. * Though this object isn't
  1237. * usually instantiated by end-users, it is the primary object interacted with when it comes time to
  1238. * add data to a view.
  1239. *
  1240. * ### Example
  1241. *
  1242. * ```
  1243. * http.request('my-friends.txt').subscribe(response => this.friends = response.text());
  1244. * ```
  1245. *
  1246. * The Response's interface is inspired by the Response constructor defined in the [Fetch
  1247. * Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
  1248. * can be accessed many times. There are other differences in the implementation, but this is the
  1249. * most significant.
  1250. *
  1251. * @deprecated use \@angular/common/http instead
  1252. */
  1253. var Response = /** @class */ (function (_super) {
  1254. __extends(Response, _super);
  1255. function Response(responseOptions) {
  1256. var _this = _super.call(this) || this;
  1257. _this._body = responseOptions.body;
  1258. _this.status = /** @type {?} */ ((responseOptions.status));
  1259. _this.ok = (_this.status >= 200 && _this.status <= 299);
  1260. _this.statusText = responseOptions.statusText;
  1261. _this.headers = responseOptions.headers;
  1262. _this.type = /** @type {?} */ ((responseOptions.type));
  1263. _this.url = /** @type {?} */ ((responseOptions.url));
  1264. return _this;
  1265. }
  1266. /**
  1267. * @return {?}
  1268. */
  1269. Response.prototype.toString = /**
  1270. * @return {?}
  1271. */
  1272. function () {
  1273. return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url;
  1274. };
  1275. return Response;
  1276. }(Body));
  1277. /**
  1278. * @fileoverview added by tsickle
  1279. * @suppress {checkTypes} checked by tsc
  1280. */
  1281. /**
  1282. * @license
  1283. * Copyright Google Inc. All Rights Reserved.
  1284. *
  1285. * Use of this source code is governed by an MIT-style license that can be
  1286. * found in the LICENSE file at https://angular.io/license
  1287. */
  1288. var _nextRequestId = 0;
  1289. var JSONP_HOME = '__ng_jsonp__';
  1290. var _jsonpConnections = null;
  1291. /**
  1292. * @return {?}
  1293. */
  1294. function _getJsonpConnections() {
  1295. var /** @type {?} */ w = typeof window == 'object' ? window : {};
  1296. if (_jsonpConnections === null) {
  1297. _jsonpConnections = w[JSONP_HOME] = {};
  1298. }
  1299. return _jsonpConnections;
  1300. }
  1301. var BrowserJsonp = /** @class */ (function () {
  1302. function BrowserJsonp() {
  1303. }
  1304. // Construct a <script> element with the specified URL
  1305. /**
  1306. * @param {?} url
  1307. * @return {?}
  1308. */
  1309. BrowserJsonp.prototype.build = /**
  1310. * @param {?} url
  1311. * @return {?}
  1312. */
  1313. function (url) {
  1314. var /** @type {?} */ node = document.createElement('script');
  1315. node.src = url;
  1316. return node;
  1317. };
  1318. /**
  1319. * @return {?}
  1320. */
  1321. BrowserJsonp.prototype.nextRequestID = /**
  1322. * @return {?}
  1323. */
  1324. function () { return "__req" + _nextRequestId++; };
  1325. /**
  1326. * @param {?} id
  1327. * @return {?}
  1328. */
  1329. BrowserJsonp.prototype.requestCallback = /**
  1330. * @param {?} id
  1331. * @return {?}
  1332. */
  1333. function (id) { return JSONP_HOME + "." + id + ".finished"; };
  1334. /**
  1335. * @param {?} id
  1336. * @param {?} connection
  1337. * @return {?}
  1338. */
  1339. BrowserJsonp.prototype.exposeConnection = /**
  1340. * @param {?} id
  1341. * @param {?} connection
  1342. * @return {?}
  1343. */
  1344. function (id, connection) {
  1345. var /** @type {?} */ connections = _getJsonpConnections();
  1346. connections[id] = connection;
  1347. };
  1348. /**
  1349. * @param {?} id
  1350. * @return {?}
  1351. */
  1352. BrowserJsonp.prototype.removeConnection = /**
  1353. * @param {?} id
  1354. * @return {?}
  1355. */
  1356. function (id) {
  1357. var /** @type {?} */ connections = _getJsonpConnections();
  1358. connections[id] = null;
  1359. };
  1360. // Attach the <script> element to the DOM
  1361. /**
  1362. * @param {?} node
  1363. * @return {?}
  1364. */
  1365. BrowserJsonp.prototype.send = /**
  1366. * @param {?} node
  1367. * @return {?}
  1368. */
  1369. function (node) { document.body.appendChild(/** @type {?} */ ((node))); };
  1370. // Remove <script> element from the DOM
  1371. /**
  1372. * @param {?} node
  1373. * @return {?}
  1374. */
  1375. BrowserJsonp.prototype.cleanup = /**
  1376. * @param {?} node
  1377. * @return {?}
  1378. */
  1379. function (node) {
  1380. if (node.parentNode) {
  1381. node.parentNode.removeChild(/** @type {?} */ ((node)));
  1382. }
  1383. };
  1384. BrowserJsonp.decorators = [
  1385. { type: _angular_core.Injectable },
  1386. ];
  1387. /** @nocollapse */
  1388. BrowserJsonp.ctorParameters = function () { return []; };
  1389. return BrowserJsonp;
  1390. }());
  1391. /**
  1392. * @fileoverview added by tsickle
  1393. * @suppress {checkTypes} checked by tsc
  1394. */
  1395. /**
  1396. * @license
  1397. * Copyright Google Inc. All Rights Reserved.
  1398. *
  1399. * Use of this source code is governed by an MIT-style license that can be
  1400. * found in the LICENSE file at https://angular.io/license
  1401. */
  1402. var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
  1403. var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
  1404. /**
  1405. * Base class for an in-flight JSONP request.
  1406. *
  1407. * @deprecated use \@angular/common/http instead
  1408. */
  1409. var JSONPConnection = /** @class */ (function () {
  1410. /** @internal */
  1411. function JSONPConnection(req, _dom, baseResponseOptions) {
  1412. var _this = this;
  1413. this._dom = _dom;
  1414. this.baseResponseOptions = baseResponseOptions;
  1415. this._finished = false;
  1416. if (req.method !== RequestMethod.Get) {
  1417. throw new TypeError(JSONP_ERR_WRONG_METHOD);
  1418. }
  1419. this.request = req;
  1420. this.response = new rxjs_Observable.Observable(function (responseObserver) {
  1421. _this.readyState = ReadyState.Loading;
  1422. var /** @type {?} */ id = _this._id = _dom.nextRequestID();
  1423. _dom.exposeConnection(id, _this);
  1424. // Workaround Dart
  1425. // url = url.replace(/=JSONP_CALLBACK(&|$)/, `generated method`);
  1426. var /** @type {?} */ callback = _dom.requestCallback(_this._id);
  1427. var /** @type {?} */ url = req.url;
  1428. if (url.indexOf('=JSONP_CALLBACK&') > -1) {
  1429. url = url.replace('=JSONP_CALLBACK&', "=" + callback + "&");
  1430. }
  1431. else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
  1432. url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + ("=" + callback);
  1433. }
  1434. var /** @type {?} */ script = _this._script = _dom.build(url);
  1435. var /** @type {?} */ onLoad = function (event) {
  1436. if (_this.readyState === ReadyState.Cancelled)
  1437. return;
  1438. _this.readyState = ReadyState.Done;
  1439. _dom.cleanup(script);
  1440. if (!_this._finished) {
  1441. var /** @type {?} */ responseOptions_1 = new ResponseOptions({ body: JSONP_ERR_NO_CALLBACK, type: ResponseType.Error, url: url });
  1442. if (baseResponseOptions) {
  1443. responseOptions_1 = baseResponseOptions.merge(responseOptions_1);
  1444. }
  1445. responseObserver.error(new Response(responseOptions_1));
  1446. return;
  1447. }
  1448. var /** @type {?} */ responseOptions = new ResponseOptions({ body: _this._responseData, url: url });
  1449. if (_this.baseResponseOptions) {
  1450. responseOptions = _this.baseResponseOptions.merge(responseOptions);
  1451. }
  1452. responseObserver.next(new Response(responseOptions));
  1453. responseObserver.complete();
  1454. };
  1455. var /** @type {?} */ onError = function (error) {
  1456. if (_this.readyState === ReadyState.Cancelled)
  1457. return;
  1458. _this.readyState = ReadyState.Done;
  1459. _dom.cleanup(script);
  1460. var /** @type {?} */ responseOptions = new ResponseOptions({ body: error.message, type: ResponseType.Error });
  1461. if (baseResponseOptions) {
  1462. responseOptions = baseResponseOptions.merge(responseOptions);
  1463. }
  1464. responseObserver.error(new Response(responseOptions));
  1465. };
  1466. script.addEventListener('load', onLoad);
  1467. script.addEventListener('error', onError);
  1468. _dom.send(script);
  1469. return function () {
  1470. _this.readyState = ReadyState.Cancelled;
  1471. script.removeEventListener('load', onLoad);
  1472. script.removeEventListener('error', onError);
  1473. _this._dom.cleanup(script);
  1474. };
  1475. });
  1476. }
  1477. /**
  1478. * Callback called when the JSONP request completes, to notify the application
  1479. * of the new data.
  1480. */
  1481. /**
  1482. * Callback called when the JSONP request completes, to notify the application
  1483. * of the new data.
  1484. * @param {?=} data
  1485. * @return {?}
  1486. */
  1487. JSONPConnection.prototype.finished = /**
  1488. * Callback called when the JSONP request completes, to notify the application
  1489. * of the new data.
  1490. * @param {?=} data
  1491. * @return {?}
  1492. */
  1493. function (data) {
  1494. // Don't leak connections
  1495. this._finished = true;
  1496. this._dom.removeConnection(this._id);
  1497. if (this.readyState === ReadyState.Cancelled)
  1498. return;
  1499. this._responseData = data;
  1500. };
  1501. return JSONPConnection;
  1502. }());
  1503. /**
  1504. * A {\@link ConnectionBackend} that uses the JSONP strategy of making requests.
  1505. *
  1506. * @deprecated use \@angular/common/http instead
  1507. */
  1508. var JSONPBackend = /** @class */ (function (_super) {
  1509. __extends(JSONPBackend, _super);
  1510. /** @internal */
  1511. function JSONPBackend(_browserJSONP, _baseResponseOptions) {
  1512. var _this = _super.call(this) || this;
  1513. _this._browserJSONP = _browserJSONP;
  1514. _this._baseResponseOptions = _baseResponseOptions;
  1515. return _this;
  1516. }
  1517. /**
  1518. * @param {?} request
  1519. * @return {?}
  1520. */
  1521. JSONPBackend.prototype.createConnection = /**
  1522. * @param {?} request
  1523. * @return {?}
  1524. */
  1525. function (request) {
  1526. return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);
  1527. };
  1528. JSONPBackend.decorators = [
  1529. { type: _angular_core.Injectable },
  1530. ];
  1531. /** @nocollapse */
  1532. JSONPBackend.ctorParameters = function () { return [
  1533. { type: BrowserJsonp, },
  1534. { type: ResponseOptions, },
  1535. ]; };
  1536. return JSONPBackend;
  1537. }(ConnectionBackend));
  1538. /**
  1539. * @fileoverview added by tsickle
  1540. * @suppress {checkTypes} checked by tsc
  1541. */
  1542. /**
  1543. * @license
  1544. * Copyright Google Inc. All Rights Reserved.
  1545. *
  1546. * Use of this source code is governed by an MIT-style license that can be
  1547. * found in the LICENSE file at https://angular.io/license
  1548. */
  1549. var XSSI_PREFIX = /^\)\]\}',?\n/;
  1550. /**
  1551. * Creates connections using `XMLHttpRequest`. Given a fully-qualified
  1552. * request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
  1553. * request.
  1554. *
  1555. * This class would typically not be created or interacted with directly inside applications, though
  1556. * the {\@link MockConnection} may be interacted with in tests.
  1557. *
  1558. * @deprecated use \@angular/common/http instead
  1559. */
  1560. var XHRConnection = /** @class */ (function () {
  1561. function XHRConnection(req, browserXHR, baseResponseOptions) {
  1562. var _this = this;
  1563. this.request = req;
  1564. this.response = new rxjs_Observable.Observable(function (responseObserver) {
  1565. var /** @type {?} */ _xhr = browserXHR.build();
  1566. _xhr.open(RequestMethod[req.method].toUpperCase(), req.url);
  1567. if (req.withCredentials != null) {
  1568. _xhr.withCredentials = req.withCredentials;
  1569. }
  1570. // load event handler
  1571. var /** @type {?} */ onLoad = function () {
  1572. // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
  1573. var /** @type {?} */ status = _xhr.status === 1223 ? 204 : _xhr.status;
  1574. var /** @type {?} */ body = null;
  1575. // HTTP 204 means no content
  1576. if (status !== 204) {
  1577. // responseText is the old-school way of retrieving response (supported by IE8 & 9)
  1578. // response/responseType properties were introduced in ResourceLoader Level2 spec
  1579. // (supported by IE10)
  1580. body = (typeof _xhr.response === 'undefined') ? _xhr.responseText : _xhr.response;
  1581. // Implicitly strip a potential XSSI prefix.
  1582. if (typeof body === 'string') {
  1583. body = body.replace(XSSI_PREFIX, '');
  1584. }
  1585. }
  1586. // fix status code when it is 0 (0 status is undocumented).
  1587. // Occurs when accessing file resources or on Android 4.1 stock browser
  1588. // while retrieving files from application cache.
  1589. if (status === 0) {
  1590. status = body ? 200 : 0;
  1591. }
  1592. var /** @type {?} */ headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
  1593. // IE 9 does not provide the way to get URL of response
  1594. var /** @type {?} */ url = getResponseURL(_xhr) || req.url;
  1595. var /** @type {?} */ statusText = _xhr.statusText || 'OK';
  1596. var /** @type {?} */ responseOptions = new ResponseOptions({ body: body, status: status, headers: headers, statusText: statusText, url: url });
  1597. if (baseResponseOptions != null) {
  1598. responseOptions = baseResponseOptions.merge(responseOptions);
  1599. }
  1600. var /** @type {?} */ response = new Response(responseOptions);
  1601. response.ok = isSuccess(status);
  1602. if (response.ok) {
  1603. responseObserver.next(response);
  1604. // TODO(gdi2290): defer complete if array buffer until done
  1605. responseObserver.complete();
  1606. return;
  1607. }
  1608. responseObserver.error(response);
  1609. };
  1610. // error event handler
  1611. var /** @type {?} */ onError = function (err) {
  1612. var /** @type {?} */ responseOptions = new ResponseOptions({
  1613. body: err,
  1614. type: ResponseType.Error,
  1615. status: _xhr.status,
  1616. statusText: _xhr.statusText,
  1617. });
  1618. if (baseResponseOptions != null) {
  1619. responseOptions = baseResponseOptions.merge(responseOptions);
  1620. }
  1621. responseObserver.error(new Response(responseOptions));
  1622. };
  1623. _this.setDetectedContentType(req, _xhr);
  1624. if (req.headers == null) {
  1625. req.headers = new Headers();
  1626. }
  1627. if (!req.headers.has('Accept')) {
  1628. req.headers.append('Accept', 'application/json, text/plain, */*');
  1629. }
  1630. req.headers.forEach(function (values, name) { return _xhr.setRequestHeader(/** @type {?} */ ((name)), values.join(',')); });
  1631. // Select the correct buffer type to store the response
  1632. if (req.responseType != null && _xhr.responseType != null) {
  1633. switch (req.responseType) {
  1634. case ResponseContentType.ArrayBuffer:
  1635. _xhr.responseType = 'arraybuffer';
  1636. break;
  1637. case ResponseContentType.Json:
  1638. _xhr.responseType = 'json';
  1639. break;
  1640. case ResponseContentType.Text:
  1641. _xhr.responseType = 'text';
  1642. break;
  1643. case ResponseContentType.Blob:
  1644. _xhr.responseType = 'blob';
  1645. break;
  1646. default:
  1647. throw new Error('The selected responseType is not supported');
  1648. }
  1649. }
  1650. _xhr.addEventListener('load', onLoad);
  1651. _xhr.addEventListener('error', onError);
  1652. _xhr.send(_this.request.getBody());
  1653. return function () {
  1654. _xhr.removeEventListener('load', onLoad);
  1655. _xhr.removeEventListener('error', onError);
  1656. _xhr.abort();
  1657. };
  1658. });
  1659. }
  1660. /**
  1661. * @param {?} req
  1662. * @param {?} _xhr
  1663. * @return {?}
  1664. */
  1665. XHRConnection.prototype.setDetectedContentType = /**
  1666. * @param {?} req
  1667. * @param {?} _xhr
  1668. * @return {?}
  1669. */
  1670. function (req /** TODO Request */, _xhr /** XMLHttpRequest */) {
  1671. // Skip if a custom Content-Type header is provided
  1672. if (req.headers != null && req.headers.get('Content-Type') != null) {
  1673. return;
  1674. }
  1675. // Set the detected content type
  1676. switch (req.contentType) {
  1677. case ContentType.NONE:
  1678. break;
  1679. case ContentType.JSON:
  1680. _xhr.setRequestHeader('content-type', 'application/json');
  1681. break;
  1682. case ContentType.FORM:
  1683. _xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  1684. break;
  1685. case ContentType.TEXT:
  1686. _xhr.setRequestHeader('content-type', 'text/plain');
  1687. break;
  1688. case ContentType.BLOB:
  1689. var /** @type {?} */ blob = req.blob();
  1690. if (blob.type) {
  1691. _xhr.setRequestHeader('content-type', blob.type);
  1692. }
  1693. break;
  1694. }
  1695. };
  1696. return XHRConnection;
  1697. }());
  1698. /**
  1699. * `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
  1700. * using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
  1701. * for more information on XSRF.
  1702. *
  1703. * Applications can configure custom cookie and header names by binding an instance of this class
  1704. * with different `cookieName` and `headerName` values. See the main HTTP documentation for more
  1705. * details.
  1706. *
  1707. * @deprecated use \@angular/common/http instead
  1708. */
  1709. var CookieXSRFStrategy = /** @class */ (function () {
  1710. function CookieXSRFStrategy(_cookieName, _headerName) {
  1711. if (_cookieName === void 0) { _cookieName = 'XSRF-TOKEN'; }
  1712. if (_headerName === void 0) { _headerName = 'X-XSRF-TOKEN'; }
  1713. this._cookieName = _cookieName;
  1714. this._headerName = _headerName;
  1715. }
  1716. /**
  1717. * @param {?} req
  1718. * @return {?}
  1719. */
  1720. CookieXSRFStrategy.prototype.configureRequest = /**
  1721. * @param {?} req
  1722. * @return {?}
  1723. */
  1724. function (req) {
  1725. var /** @type {?} */ xsrfToken = _angular_platformBrowser.ɵgetDOM().getCookie(this._cookieName);
  1726. if (xsrfToken) {
  1727. req.headers.set(this._headerName, xsrfToken);
  1728. }
  1729. };
  1730. return CookieXSRFStrategy;
  1731. }());
  1732. /**
  1733. * Creates {\@link XHRConnection} instances.
  1734. *
  1735. * This class would typically not be used by end users, but could be
  1736. * overridden if a different backend implementation should be used,
  1737. * such as in a node backend.
  1738. *
  1739. * ### Example
  1740. *
  1741. * ```
  1742. * import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '\@angular/http';
  1743. * \@Component({
  1744. * viewProviders: [
  1745. * HTTP_PROVIDERS,
  1746. * {provide: Http, useFactory: (backend, options) => {
  1747. * return new Http(backend, options);
  1748. * }, deps: [MyNodeBackend, BaseRequestOptions]}]
  1749. * })
  1750. * class MyComponent {
  1751. * constructor(http:Http) {
  1752. * http.request('people.json').subscribe(res => this.people = res.json());
  1753. * }
  1754. * }
  1755. * ```
  1756. * @deprecated use \@angular/common/http instead
  1757. */
  1758. var XHRBackend = /** @class */ (function () {
  1759. function XHRBackend(_browserXHR, _baseResponseOptions, _xsrfStrategy) {
  1760. this._browserXHR = _browserXHR;
  1761. this._baseResponseOptions = _baseResponseOptions;
  1762. this._xsrfStrategy = _xsrfStrategy;
  1763. }
  1764. /**
  1765. * @param {?} request
  1766. * @return {?}
  1767. */
  1768. XHRBackend.prototype.createConnection = /**
  1769. * @param {?} request
  1770. * @return {?}
  1771. */
  1772. function (request) {
  1773. this._xsrfStrategy.configureRequest(request);
  1774. return new XHRConnection(request, this._browserXHR, this._baseResponseOptions);
  1775. };
  1776. XHRBackend.decorators = [
  1777. { type: _angular_core.Injectable },
  1778. ];
  1779. /** @nocollapse */
  1780. XHRBackend.ctorParameters = function () { return [
  1781. { type: BrowserXhr, },
  1782. { type: ResponseOptions, },
  1783. { type: XSRFStrategy, },
  1784. ]; };
  1785. return XHRBackend;
  1786. }());
  1787. /**
  1788. * @fileoverview added by tsickle
  1789. * @suppress {checkTypes} checked by tsc
  1790. */
  1791. /**
  1792. * @license
  1793. * Copyright Google Inc. All Rights Reserved.
  1794. *
  1795. * Use of this source code is governed by an MIT-style license that can be
  1796. * found in the LICENSE file at https://angular.io/license
  1797. */
  1798. /**
  1799. * Creates a request options object to be optionally provided when instantiating a
  1800. * {\@link Request}.
  1801. *
  1802. * This class is based on the `RequestInit` description in the [Fetch
  1803. * Spec](https://fetch.spec.whatwg.org/#requestinit).
  1804. *
  1805. * All values are null by default. Typical defaults can be found in the {\@link BaseRequestOptions}
  1806. * class, which sub-classes `RequestOptions`.
  1807. *
  1808. * ```typescript
  1809. * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
  1810. *
  1811. * const options = new RequestOptions({
  1812. * method: RequestMethod.Post,
  1813. * url: 'https://google.com'
  1814. * });
  1815. * const req = new Request(options);
  1816. * console.log('req.method:', RequestMethod[req.method]); // Post
  1817. * console.log('options.url:', options.url); // https://google.com
  1818. * ```
  1819. *
  1820. * @deprecated use \@angular/common/http instead
  1821. */
  1822. var RequestOptions = /** @class */ (function () {
  1823. // TODO(Dzmitry): remove search when this.search is removed
  1824. function RequestOptions(opts) {
  1825. if (opts === void 0) { opts = {}; }
  1826. 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;
  1827. this.method = method != null ? normalizeMethodName(method) : null;
  1828. this.headers = headers != null ? headers : null;
  1829. this.body = body != null ? body : null;
  1830. this.url = url != null ? url : null;
  1831. this.params = this._mergeSearchParams(params || search);
  1832. this.withCredentials = withCredentials != null ? withCredentials : null;
  1833. this.responseType = responseType != null ? responseType : null;
  1834. }
  1835. Object.defineProperty(RequestOptions.prototype, "search", {
  1836. /**
  1837. * @deprecated from 4.0.0. Use params instead.
  1838. */
  1839. get: /**
  1840. * @deprecated from 4.0.0. Use params instead.
  1841. * @return {?}
  1842. */
  1843. function () { return this.params; },
  1844. /**
  1845. * @deprecated from 4.0.0. Use params instead.
  1846. */
  1847. set: /**
  1848. * @deprecated from 4.0.0. Use params instead.
  1849. * @param {?} params
  1850. * @return {?}
  1851. */
  1852. function (params) { this.params = params; },
  1853. enumerable: true,
  1854. configurable: true
  1855. });
  1856. /**
  1857. * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
  1858. * existing values. This method will not change the values of the instance on which it is being
  1859. * called.
  1860. *
  1861. * Note that `headers` and `search` will override existing values completely if present in
  1862. * the `options` object. If these values should be merged, it should be done prior to calling
  1863. * `merge` on the `RequestOptions` instance.
  1864. *
  1865. * ```typescript
  1866. * import {RequestOptions, Request, RequestMethod} from '@angular/http';
  1867. *
  1868. * const options = new RequestOptions({
  1869. * method: RequestMethod.Post
  1870. * });
  1871. * const req = new Request(options.merge({
  1872. * url: 'https://google.com'
  1873. * }));
  1874. * console.log('req.method:', RequestMethod[req.method]); // Post
  1875. * console.log('options.url:', options.url); // null
  1876. * console.log('req.url:', req.url); // https://google.com
  1877. * ```
  1878. */
  1879. /**
  1880. * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
  1881. * existing values. This method will not change the values of the instance on which it is being
  1882. * called.
  1883. *
  1884. * Note that `headers` and `search` will override existing values completely if present in
  1885. * the `options` object. If these values should be merged, it should be done prior to calling
  1886. * `merge` on the `RequestOptions` instance.
  1887. *
  1888. * ```typescript
  1889. * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
  1890. *
  1891. * const options = new RequestOptions({
  1892. * method: RequestMethod.Post
  1893. * });
  1894. * const req = new Request(options.merge({
  1895. * url: 'https://google.com'
  1896. * }));
  1897. * console.log('req.method:', RequestMethod[req.method]); // Post
  1898. * console.log('options.url:', options.url); // null
  1899. * console.log('req.url:', req.url); // https://google.com
  1900. * ```
  1901. * @param {?=} options
  1902. * @return {?}
  1903. */
  1904. RequestOptions.prototype.merge = /**
  1905. * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
  1906. * existing values. This method will not change the values of the instance on which it is being
  1907. * called.
  1908. *
  1909. * Note that `headers` and `search` will override existing values completely if present in
  1910. * the `options` object. If these values should be merged, it should be done prior to calling
  1911. * `merge` on the `RequestOptions` instance.
  1912. *
  1913. * ```typescript
  1914. * import {RequestOptions, Request, RequestMethod} from '\@angular/http';
  1915. *
  1916. * const options = new RequestOptions({
  1917. * method: RequestMethod.Post
  1918. * });
  1919. * const req = new Request(options.merge({
  1920. * url: 'https://google.com'
  1921. * }));
  1922. * console.log('req.method:', RequestMethod[req.method]); // Post
  1923. * console.log('options.url:', options.url); // null
  1924. * console.log('req.url:', req.url); // https://google.com
  1925. * ```
  1926. * @param {?=} options
  1927. * @return {?}
  1928. */
  1929. function (options) {
  1930. return new RequestOptions({
  1931. method: options && options.method != null ? options.method : this.method,
  1932. headers: options && options.headers != null ? options.headers : new Headers(this.headers),
  1933. body: options && options.body != null ? options.body : this.body,
  1934. url: options && options.url != null ? options.url : this.url,
  1935. params: options && this._mergeSearchParams(options.params || options.search),
  1936. withCredentials: options && options.withCredentials != null ? options.withCredentials :
  1937. this.withCredentials,
  1938. responseType: options && options.responseType != null ? options.responseType :
  1939. this.responseType
  1940. });
  1941. };
  1942. /**
  1943. * @param {?=} params
  1944. * @return {?}
  1945. */
  1946. RequestOptions.prototype._mergeSearchParams = /**
  1947. * @param {?=} params
  1948. * @return {?}
  1949. */
  1950. function (params) {
  1951. if (!params)
  1952. return this.params;
  1953. if (params instanceof URLSearchParams) {
  1954. return params.clone();
  1955. }
  1956. if (typeof params === 'string') {
  1957. return new URLSearchParams(params);
  1958. }
  1959. return this._parseParams(params);
  1960. };
  1961. /**
  1962. * @param {?=} objParams
  1963. * @return {?}
  1964. */
  1965. RequestOptions.prototype._parseParams = /**
  1966. * @param {?=} objParams
  1967. * @return {?}
  1968. */
  1969. function (objParams) {
  1970. var _this = this;
  1971. if (objParams === void 0) { objParams = {}; }
  1972. var /** @type {?} */ params = new URLSearchParams();
  1973. Object.keys(objParams).forEach(function (key) {
  1974. var /** @type {?} */ value = objParams[key];
  1975. if (Array.isArray(value)) {
  1976. value.forEach(function (item) { return _this._appendParam(key, item, params); });
  1977. }
  1978. else {
  1979. _this._appendParam(key, value, params);
  1980. }
  1981. });
  1982. return params;
  1983. };
  1984. /**
  1985. * @param {?} key
  1986. * @param {?} value
  1987. * @param {?} params
  1988. * @return {?}
  1989. */
  1990. RequestOptions.prototype._appendParam = /**
  1991. * @param {?} key
  1992. * @param {?} value
  1993. * @param {?} params
  1994. * @return {?}
  1995. */
  1996. function (key, value, params) {
  1997. if (typeof value !== 'string') {
  1998. value = JSON.stringify(value);
  1999. }
  2000. params.append(key, value);
  2001. };
  2002. return RequestOptions;
  2003. }());
  2004. /**
  2005. * Subclass of {\@link RequestOptions}, with default values.
  2006. *
  2007. * Default values:
  2008. * * method: {\@link RequestMethod RequestMethod.Get}
  2009. * * headers: empty {\@link Headers} object
  2010. *
  2011. * This class could be extended and bound to the {\@link RequestOptions} class
  2012. * when configuring an {\@link Injector}, in order to override the default options
  2013. * used by {\@link Http} to create and send {\@link Request Requests}.
  2014. *
  2015. * ```typescript
  2016. * import {BaseRequestOptions, RequestOptions} from '\@angular/http';
  2017. *
  2018. * class MyOptions extends BaseRequestOptions {
  2019. * search: string = 'coreTeam=true';
  2020. * }
  2021. *
  2022. * {provide: RequestOptions, useClass: MyOptions};
  2023. * ```
  2024. *
  2025. * The options could also be extended when manually creating a {\@link Request}
  2026. * object.
  2027. *
  2028. * ```
  2029. * import {BaseRequestOptions, Request, RequestMethod} from '\@angular/http';
  2030. *
  2031. * const options = new BaseRequestOptions();
  2032. * const req = new Request(options.merge({
  2033. * method: RequestMethod.Post,
  2034. * url: 'https://google.com'
  2035. * }));
  2036. * console.log('req.method:', RequestMethod[req.method]); // Post
  2037. * console.log('options.url:', options.url); // null
  2038. * console.log('req.url:', req.url); // https://google.com
  2039. * ```
  2040. *
  2041. * @deprecated use \@angular/common/http instead
  2042. */
  2043. var BaseRequestOptions = /** @class */ (function (_super) {
  2044. __extends(BaseRequestOptions, _super);
  2045. function BaseRequestOptions() {
  2046. return _super.call(this, { method: RequestMethod.Get, headers: new Headers() }) || this;
  2047. }
  2048. BaseRequestOptions.decorators = [
  2049. { type: _angular_core.Injectable },
  2050. ];
  2051. /** @nocollapse */
  2052. BaseRequestOptions.ctorParameters = function () { return []; };
  2053. return BaseRequestOptions;
  2054. }(RequestOptions));
  2055. /**
  2056. * @fileoverview added by tsickle
  2057. * @suppress {checkTypes} checked by tsc
  2058. */
  2059. /**
  2060. * @license
  2061. * Copyright Google Inc. All Rights Reserved.
  2062. *
  2063. * Use of this source code is governed by an MIT-style license that can be
  2064. * found in the LICENSE file at https://angular.io/license
  2065. */
  2066. /**
  2067. * Creates `Request` instances from provided values.
  2068. *
  2069. * The Request's interface is inspired by the Request constructor defined in the [Fetch
  2070. * Spec](https://fetch.spec.whatwg.org/#request-class),
  2071. * but is considered a static value whose body can be accessed many times. There are other
  2072. * differences in the implementation, but this is the most significant.
  2073. *
  2074. * `Request` instances are typically created by higher-level classes, like {\@link Http} and
  2075. * {\@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
  2076. * One such example is when creating services that wrap higher-level services, like {\@link Http},
  2077. * where it may be useful to generate a `Request` with arbitrary headers and search params.
  2078. *
  2079. * ```typescript
  2080. * import {Injectable, Injector} from '\@angular/core';
  2081. * import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '\@angular/http';
  2082. *
  2083. * \@Injectable()
  2084. * class AutoAuthenticator {
  2085. * constructor(public http:Http) {}
  2086. * request(url:string) {
  2087. * return this.http.request(new Request({
  2088. * method: RequestMethod.Get,
  2089. * url: url,
  2090. * search: 'password=123'
  2091. * }));
  2092. * }
  2093. * }
  2094. *
  2095. * var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
  2096. * var authenticator = injector.get(AutoAuthenticator);
  2097. * authenticator.request('people.json').subscribe(res => {
  2098. * //URL should have included '?password=123'
  2099. * console.log('people', res.json());
  2100. * });
  2101. * ```
  2102. *
  2103. * @deprecated use \@angular/common/http instead
  2104. */
  2105. var Request = /** @class */ (function (_super) {
  2106. __extends(Request, _super);
  2107. function Request(requestOptions) {
  2108. var _this = _super.call(this) || this;
  2109. // TODO: assert that url is present
  2110. var /** @type {?} */ url = requestOptions.url;
  2111. _this.url = /** @type {?} */ ((requestOptions.url));
  2112. var /** @type {?} */ paramsArg = requestOptions.params || requestOptions.search;
  2113. if (paramsArg) {
  2114. var /** @type {?} */ params = void 0;
  2115. if (typeof paramsArg === 'object' && !(paramsArg instanceof URLSearchParams)) {
  2116. params = urlEncodeParams(paramsArg).toString();
  2117. }
  2118. else {
  2119. params = paramsArg.toString();
  2120. }
  2121. if (params.length > 0) {
  2122. var /** @type {?} */ prefix = '?';
  2123. if (_this.url.indexOf('?') != -1) {
  2124. prefix = (_this.url[_this.url.length - 1] == '&') ? '' : '&';
  2125. }
  2126. // TODO: just delete search-query-looking string in url?
  2127. // TODO: just delete search-query-looking string in url?
  2128. _this.url = url + prefix + params;
  2129. }
  2130. }
  2131. _this._body = requestOptions.body;
  2132. _this.method = normalizeMethodName(/** @type {?} */ ((requestOptions.method)));
  2133. // TODO(jeffbcross): implement behavior
  2134. // Defaults to 'omit', consistent with browser
  2135. // TODO(jeffbcross): implement behavior
  2136. // Defaults to 'omit', consistent with browser
  2137. _this.headers = new Headers(requestOptions.headers);
  2138. _this.contentType = _this.detectContentType();
  2139. _this.withCredentials = /** @type {?} */ ((requestOptions.withCredentials));
  2140. _this.responseType = /** @type {?} */ ((requestOptions.responseType));
  2141. return _this;
  2142. }
  2143. /**
  2144. * Returns the content type enum based on header options.
  2145. */
  2146. /**
  2147. * Returns the content type enum based on header options.
  2148. * @return {?}
  2149. */
  2150. Request.prototype.detectContentType = /**
  2151. * Returns the content type enum based on header options.
  2152. * @return {?}
  2153. */
  2154. function () {
  2155. switch (this.headers.get('content-type')) {
  2156. case 'application/json':
  2157. return ContentType.JSON;
  2158. case 'application/x-www-form-urlencoded':
  2159. return ContentType.FORM;
  2160. case 'multipart/form-data':
  2161. return ContentType.FORM_DATA;
  2162. case 'text/plain':
  2163. case 'text/html':
  2164. return ContentType.TEXT;
  2165. case 'application/octet-stream':
  2166. return this._body instanceof ArrayBuffer$1 ? ContentType.ARRAY_BUFFER : ContentType.BLOB;
  2167. default:
  2168. return this.detectContentTypeFromBody();
  2169. }
  2170. };
  2171. /**
  2172. * Returns the content type of request's body based on its type.
  2173. */
  2174. /**
  2175. * Returns the content type of request's body based on its type.
  2176. * @return {?}
  2177. */
  2178. Request.prototype.detectContentTypeFromBody = /**
  2179. * Returns the content type of request's body based on its type.
  2180. * @return {?}
  2181. */
  2182. function () {
  2183. if (this._body == null) {
  2184. return ContentType.NONE;
  2185. }
  2186. else if (this._body instanceof URLSearchParams) {
  2187. return ContentType.FORM;
  2188. }
  2189. else if (this._body instanceof FormData) {
  2190. return ContentType.FORM_DATA;
  2191. }
  2192. else if (this._body instanceof Blob$1) {
  2193. return ContentType.BLOB;
  2194. }
  2195. else if (this._body instanceof ArrayBuffer$1) {
  2196. return ContentType.ARRAY_BUFFER;
  2197. }
  2198. else if (this._body && typeof this._body === 'object') {
  2199. return ContentType.JSON;
  2200. }
  2201. else {
  2202. return ContentType.TEXT;
  2203. }
  2204. };
  2205. /**
  2206. * Returns the request's body according to its type. If body is undefined, return
  2207. * null.
  2208. */
  2209. /**
  2210. * Returns the request's body according to its type. If body is undefined, return
  2211. * null.
  2212. * @return {?}
  2213. */
  2214. Request.prototype.getBody = /**
  2215. * Returns the request's body according to its type. If body is undefined, return
  2216. * null.
  2217. * @return {?}
  2218. */
  2219. function () {
  2220. switch (this.contentType) {
  2221. case ContentType.JSON:
  2222. return this.text();
  2223. case ContentType.FORM:
  2224. return this.text();
  2225. case ContentType.FORM_DATA:
  2226. return this._body;
  2227. case ContentType.TEXT:
  2228. return this.text();
  2229. case ContentType.BLOB:
  2230. return this.blob();
  2231. case ContentType.ARRAY_BUFFER:
  2232. return this.arrayBuffer();
  2233. default:
  2234. return null;
  2235. }
  2236. };
  2237. return Request;
  2238. }(Body));
  2239. /**
  2240. * @param {?} params
  2241. * @return {?}
  2242. */
  2243. function urlEncodeParams(params) {
  2244. var /** @type {?} */ searchParams = new URLSearchParams();
  2245. Object.keys(params).forEach(function (key) {
  2246. var /** @type {?} */ value = params[key];
  2247. if (value && Array.isArray(value)) {
  2248. value.forEach(function (element) { return searchParams.append(key, element.toString()); });
  2249. }
  2250. else {
  2251. searchParams.append(key, value.toString());
  2252. }
  2253. });
  2254. return searchParams;
  2255. }
  2256. var noop = function () { };
  2257. var w = typeof window == 'object' ? window : noop;
  2258. var FormData = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['FormData'] || noop;
  2259. var Blob$1 = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['Blob'] || noop;
  2260. var ArrayBuffer$1 = (/** @type {?} */ (w /** TODO #9100 */) /** TODO #9100 */)['ArrayBuffer'] || noop;
  2261. /**
  2262. * @fileoverview added by tsickle
  2263. * @suppress {checkTypes} checked by tsc
  2264. */
  2265. /**
  2266. * @license
  2267. * Copyright Google Inc. All Rights Reserved.
  2268. *
  2269. * Use of this source code is governed by an MIT-style license that can be
  2270. * found in the LICENSE file at https://angular.io/license
  2271. */
  2272. /**
  2273. * @param {?} backend
  2274. * @param {?} request
  2275. * @return {?}
  2276. */
  2277. function httpRequest(backend, request) {
  2278. return backend.createConnection(request).response;
  2279. }
  2280. /**
  2281. * @param {?} defaultOpts
  2282. * @param {?} providedOpts
  2283. * @param {?} method
  2284. * @param {?} url
  2285. * @return {?}
  2286. */
  2287. function mergeOptions(defaultOpts, providedOpts, method, url) {
  2288. var /** @type {?} */ newOptions = defaultOpts;
  2289. if (providedOpts) {
  2290. // Hack so Dart can used named parameters
  2291. return /** @type {?} */ (newOptions.merge(new RequestOptions({
  2292. method: providedOpts.method || method,
  2293. url: providedOpts.url || url,
  2294. search: providedOpts.search,
  2295. params: providedOpts.params,
  2296. headers: providedOpts.headers,
  2297. body: providedOpts.body,
  2298. withCredentials: providedOpts.withCredentials,
  2299. responseType: providedOpts.responseType
  2300. })));
  2301. }
  2302. return /** @type {?} */ (newOptions.merge(new RequestOptions({ method: method, url: url })));
  2303. }
  2304. /**
  2305. * Performs http requests using `XMLHttpRequest` as the default backend.
  2306. *
  2307. * `Http` is available as an injectable class, with methods to perform http requests. Calling
  2308. * `request` returns an `Observable` which will emit a single {\@link Response} when a
  2309. * response is received.
  2310. *
  2311. * ### Example
  2312. *
  2313. * ```typescript
  2314. * import {Http, HTTP_PROVIDERS} from '\@angular/http';
  2315. * import 'rxjs/add/operator/map'
  2316. * \@Component({
  2317. * selector: 'http-app',
  2318. * viewProviders: [HTTP_PROVIDERS],
  2319. * templateUrl: 'people.html'
  2320. * })
  2321. * class PeopleComponent {
  2322. * constructor(http: Http) {
  2323. * http.get('people.json')
  2324. * // Call map on the response observable to get the parsed people object
  2325. * .map(res => res.json())
  2326. * // Subscribe to the observable to get the parsed people object and attach it to the
  2327. * // component
  2328. * .subscribe(people => this.people = people);
  2329. * }
  2330. * }
  2331. * ```
  2332. *
  2333. *
  2334. * ### Example
  2335. *
  2336. * ```
  2337. * http.get('people.json').subscribe((res:Response) => this.people = res.json());
  2338. * ```
  2339. *
  2340. * The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" (
  2341. * {\@link XHRBackend} in this case), which could be mocked with dependency injection by replacing
  2342. * the {\@link XHRBackend} provider, as in the following example:
  2343. *
  2344. * ### Example
  2345. *
  2346. * ```typescript
  2347. * import {BaseRequestOptions, Http} from '\@angular/http';
  2348. * import {MockBackend} from '\@angular/http/testing';
  2349. * var injector = Injector.resolveAndCreate([
  2350. * BaseRequestOptions,
  2351. * MockBackend,
  2352. * {provide: Http, useFactory:
  2353. * function(backend, defaultOptions) {
  2354. * return new Http(backend, defaultOptions);
  2355. * },
  2356. * deps: [MockBackend, BaseRequestOptions]}
  2357. * ]);
  2358. * var http = injector.get(Http);
  2359. * http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));
  2360. * ```
  2361. *
  2362. * @deprecated use \@angular/common/http instead
  2363. */
  2364. var Http = /** @class */ (function () {
  2365. function Http(_backend, _defaultOptions) {
  2366. this._backend = _backend;
  2367. this._defaultOptions = _defaultOptions;
  2368. }
  2369. /**
  2370. * Performs any type of http request. First argument is required, and can either be a url or
  2371. * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
  2372. * object can be provided as the 2nd argument. The options object will be merged with the values
  2373. * of {@link BaseRequestOptions} before performing the request.
  2374. */
  2375. /**
  2376. * Performs any type of http request. First argument is required, and can either be a url or
  2377. * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
  2378. * object can be provided as the 2nd argument. The options object will be merged with the values
  2379. * of {\@link BaseRequestOptions} before performing the request.
  2380. * @param {?} url
  2381. * @param {?=} options
  2382. * @return {?}
  2383. */
  2384. Http.prototype.request = /**
  2385. * Performs any type of http request. First argument is required, and can either be a url or
  2386. * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
  2387. * object can be provided as the 2nd argument. The options object will be merged with the values
  2388. * of {\@link BaseRequestOptions} before performing the request.
  2389. * @param {?} url
  2390. * @param {?=} options
  2391. * @return {?}
  2392. */
  2393. function (url, options) {
  2394. var /** @type {?} */ responseObservable;
  2395. if (typeof url === 'string') {
  2396. responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url))));
  2397. }
  2398. else if (url instanceof Request) {
  2399. responseObservable = httpRequest(this._backend, url);
  2400. }
  2401. else {
  2402. throw new Error('First argument must be a url string or Request instance.');
  2403. }
  2404. return responseObservable;
  2405. };
  2406. /**
  2407. * Performs a request with `get` http method.
  2408. */
  2409. /**
  2410. * Performs a request with `get` http method.
  2411. * @param {?} url
  2412. * @param {?=} options
  2413. * @return {?}
  2414. */
  2415. Http.prototype.get = /**
  2416. * Performs a request with `get` http method.
  2417. * @param {?} url
  2418. * @param {?=} options
  2419. * @return {?}
  2420. */
  2421. function (url, options) {
  2422. return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
  2423. };
  2424. /**
  2425. * Performs a request with `post` http method.
  2426. */
  2427. /**
  2428. * Performs a request with `post` http method.
  2429. * @param {?} url
  2430. * @param {?} body
  2431. * @param {?=} options
  2432. * @return {?}
  2433. */
  2434. Http.prototype.post = /**
  2435. * Performs a request with `post` http method.
  2436. * @param {?} url
  2437. * @param {?} body
  2438. * @param {?=} options
  2439. * @return {?}
  2440. */
  2441. function (url, body, options) {
  2442. return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Post, url)));
  2443. };
  2444. /**
  2445. * Performs a request with `put` http method.
  2446. */
  2447. /**
  2448. * Performs a request with `put` http method.
  2449. * @param {?} url
  2450. * @param {?} body
  2451. * @param {?=} options
  2452. * @return {?}
  2453. */
  2454. Http.prototype.put = /**
  2455. * Performs a request with `put` http method.
  2456. * @param {?} url
  2457. * @param {?} body
  2458. * @param {?=} options
  2459. * @return {?}
  2460. */
  2461. function (url, body, options) {
  2462. return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Put, url)));
  2463. };
  2464. /**
  2465. * Performs a request with `delete` http method.
  2466. */
  2467. /**
  2468. * Performs a request with `delete` http method.
  2469. * @param {?} url
  2470. * @param {?=} options
  2471. * @return {?}
  2472. */
  2473. Http.prototype.delete = /**
  2474. * Performs a request with `delete` http method.
  2475. * @param {?} url
  2476. * @param {?=} options
  2477. * @return {?}
  2478. */
  2479. function (url, options) {
  2480. return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));
  2481. };
  2482. /**
  2483. * Performs a request with `patch` http method.
  2484. */
  2485. /**
  2486. * Performs a request with `patch` http method.
  2487. * @param {?} url
  2488. * @param {?} body
  2489. * @param {?=} options
  2490. * @return {?}
  2491. */
  2492. Http.prototype.patch = /**
  2493. * Performs a request with `patch` http method.
  2494. * @param {?} url
  2495. * @param {?} body
  2496. * @param {?=} options
  2497. * @return {?}
  2498. */
  2499. function (url, body, options) {
  2500. return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Patch, url)));
  2501. };
  2502. /**
  2503. * Performs a request with `head` http method.
  2504. */
  2505. /**
  2506. * Performs a request with `head` http method.
  2507. * @param {?} url
  2508. * @param {?=} options
  2509. * @return {?}
  2510. */
  2511. Http.prototype.head = /**
  2512. * Performs a request with `head` http method.
  2513. * @param {?} url
  2514. * @param {?=} options
  2515. * @return {?}
  2516. */
  2517. function (url, options) {
  2518. return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
  2519. };
  2520. /**
  2521. * Performs a request with `options` http method.
  2522. */
  2523. /**
  2524. * Performs a request with `options` http method.
  2525. * @param {?} url
  2526. * @param {?=} options
  2527. * @return {?}
  2528. */
  2529. Http.prototype.options = /**
  2530. * Performs a request with `options` http method.
  2531. * @param {?} url
  2532. * @param {?=} options
  2533. * @return {?}
  2534. */
  2535. function (url, options) {
  2536. return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));
  2537. };
  2538. Http.decorators = [
  2539. { type: _angular_core.Injectable },
  2540. ];
  2541. /** @nocollapse */
  2542. Http.ctorParameters = function () { return [
  2543. { type: ConnectionBackend, },
  2544. { type: RequestOptions, },
  2545. ]; };
  2546. return Http;
  2547. }());
  2548. /**
  2549. * @deprecated use \@angular/common/http instead
  2550. */
  2551. var Jsonp = /** @class */ (function (_super) {
  2552. __extends(Jsonp, _super);
  2553. function Jsonp(backend, defaultOptions) {
  2554. return _super.call(this, backend, defaultOptions) || this;
  2555. }
  2556. /**
  2557. * Performs any type of http request. First argument is required, and can either be a url or
  2558. * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
  2559. * object can be provided as the 2nd argument. The options object will be merged with the values
  2560. * of {@link BaseRequestOptions} before performing the request.
  2561. *
  2562. * @security Regular XHR is the safest alternative to JSONP for most applications, and is
  2563. * supported by all current browsers. Because JSONP creates a `<script>` element with
  2564. * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
  2565. * source could expose your application to XSS risks. Data exposed by JSONP may also be
  2566. * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
  2567. * future security issues (e.g. content sniffing). For more detail, see the
  2568. * [Security Guide](http://g.co/ng/security).
  2569. */
  2570. /**
  2571. * Performs any type of http request. First argument is required, and can either be a url or
  2572. * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
  2573. * object can be provided as the 2nd argument. The options object will be merged with the values
  2574. * of {\@link BaseRequestOptions} before performing the request.
  2575. *
  2576. * \@security Regular XHR is the safest alternative to JSONP for most applications, and is
  2577. * supported by all current browsers. Because JSONP creates a `<script>` element with
  2578. * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
  2579. * source could expose your application to XSS risks. Data exposed by JSONP may also be
  2580. * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
  2581. * future security issues (e.g. content sniffing). For more detail, see the
  2582. * [Security Guide](http://g.co/ng/security).
  2583. * @param {?} url
  2584. * @param {?=} options
  2585. * @return {?}
  2586. */
  2587. Jsonp.prototype.request = /**
  2588. * Performs any type of http request. First argument is required, and can either be a url or
  2589. * a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
  2590. * object can be provided as the 2nd argument. The options object will be merged with the values
  2591. * of {\@link BaseRequestOptions} before performing the request.
  2592. *
  2593. * \@security Regular XHR is the safest alternative to JSONP for most applications, and is
  2594. * supported by all current browsers. Because JSONP creates a `<script>` element with
  2595. * contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
  2596. * source could expose your application to XSS risks. Data exposed by JSONP may also be
  2597. * readable by malicious third-party websites. In addition, JSONP introduces potential risk for
  2598. * future security issues (e.g. content sniffing). For more detail, see the
  2599. * [Security Guide](http://g.co/ng/security).
  2600. * @param {?} url
  2601. * @param {?=} options
  2602. * @return {?}
  2603. */
  2604. function (url, options) {
  2605. var /** @type {?} */ responseObservable;
  2606. if (typeof url === 'string') {
  2607. url =
  2608. new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url)));
  2609. }
  2610. if (url instanceof Request) {
  2611. if (url.method !== RequestMethod.Get) {
  2612. throw new Error('JSONP requests must use GET request method.');
  2613. }
  2614. responseObservable = httpRequest(this._backend, url);
  2615. }
  2616. else {
  2617. throw new Error('First argument must be a url string or Request instance.');
  2618. }
  2619. return responseObservable;
  2620. };
  2621. Jsonp.decorators = [
  2622. { type: _angular_core.Injectable },
  2623. ];
  2624. /** @nocollapse */
  2625. Jsonp.ctorParameters = function () { return [
  2626. { type: ConnectionBackend, },
  2627. { type: RequestOptions, },
  2628. ]; };
  2629. return Jsonp;
  2630. }(Http));
  2631. /**
  2632. * @fileoverview added by tsickle
  2633. * @suppress {checkTypes} checked by tsc
  2634. */
  2635. /**
  2636. * @license
  2637. * Copyright Google Inc. All Rights Reserved.
  2638. *
  2639. * Use of this source code is governed by an MIT-style license that can be
  2640. * found in the LICENSE file at https://angular.io/license
  2641. */
  2642. /**
  2643. * @return {?}
  2644. */
  2645. function _createDefaultCookieXSRFStrategy() {
  2646. return new CookieXSRFStrategy();
  2647. }
  2648. /**
  2649. * @param {?} xhrBackend
  2650. * @param {?} requestOptions
  2651. * @return {?}
  2652. */
  2653. function httpFactory(xhrBackend, requestOptions) {
  2654. return new Http(xhrBackend, requestOptions);
  2655. }
  2656. /**
  2657. * @param {?} jsonpBackend
  2658. * @param {?} requestOptions
  2659. * @return {?}
  2660. */
  2661. function jsonpFactory(jsonpBackend, requestOptions) {
  2662. return new Jsonp(jsonpBackend, requestOptions);
  2663. }
  2664. /**
  2665. * The module that includes http's providers
  2666. *
  2667. * @deprecated use \@angular/common/http instead
  2668. */
  2669. var HttpModule = /** @class */ (function () {
  2670. function HttpModule() {
  2671. }
  2672. HttpModule.decorators = [
  2673. { type: _angular_core.NgModule, args: [{
  2674. providers: [
  2675. // TODO(pascal): use factory type annotations once supported in DI
  2676. // issue: https://github.com/angular/angular/issues/3183
  2677. { provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions] },
  2678. BrowserXhr,
  2679. { provide: RequestOptions, useClass: BaseRequestOptions },
  2680. { provide: ResponseOptions, useClass: BaseResponseOptions },
  2681. XHRBackend,
  2682. { provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy },
  2683. ],
  2684. },] },
  2685. ];
  2686. /** @nocollapse */
  2687. HttpModule.ctorParameters = function () { return []; };
  2688. return HttpModule;
  2689. }());
  2690. /**
  2691. * The module that includes jsonp's providers
  2692. *
  2693. * @deprecated use \@angular/common/http instead
  2694. */
  2695. var JsonpModule = /** @class */ (function () {
  2696. function JsonpModule() {
  2697. }
  2698. JsonpModule.decorators = [
  2699. { type: _angular_core.NgModule, args: [{
  2700. providers: [
  2701. // TODO(pascal): use factory type annotations once supported in DI
  2702. // issue: https://github.com/angular/angular/issues/3183
  2703. { provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions] },
  2704. BrowserJsonp,
  2705. { provide: RequestOptions, useClass: BaseRequestOptions },
  2706. { provide: ResponseOptions, useClass: BaseResponseOptions },
  2707. JSONPBackend,
  2708. ],
  2709. },] },
  2710. ];
  2711. /** @nocollapse */
  2712. JsonpModule.ctorParameters = function () { return []; };
  2713. return JsonpModule;
  2714. }());
  2715. /**
  2716. * @fileoverview added by tsickle
  2717. * @suppress {checkTypes} checked by tsc
  2718. */
  2719. /**
  2720. * @license
  2721. * Copyright Google Inc. All Rights Reserved.
  2722. *
  2723. * Use of this source code is governed by an MIT-style license that can be
  2724. * found in the LICENSE file at https://angular.io/license
  2725. */
  2726. /**
  2727. * @deprecated use \@angular/common/http instead
  2728. */
  2729. var VERSION = new _angular_core.Version('5.2.11');
  2730. exports.BrowserXhr = BrowserXhr;
  2731. exports.JSONPBackend = JSONPBackend;
  2732. exports.JSONPConnection = JSONPConnection;
  2733. exports.CookieXSRFStrategy = CookieXSRFStrategy;
  2734. exports.XHRBackend = XHRBackend;
  2735. exports.XHRConnection = XHRConnection;
  2736. exports.BaseRequestOptions = BaseRequestOptions;
  2737. exports.RequestOptions = RequestOptions;
  2738. exports.BaseResponseOptions = BaseResponseOptions;
  2739. exports.ResponseOptions = ResponseOptions;
  2740. exports.ReadyState = ReadyState;
  2741. exports.RequestMethod = RequestMethod;
  2742. exports.ResponseContentType = ResponseContentType;
  2743. exports.ResponseType = ResponseType;
  2744. exports.Headers = Headers;
  2745. exports.Http = Http;
  2746. exports.Jsonp = Jsonp;
  2747. exports.HttpModule = HttpModule;
  2748. exports.JsonpModule = JsonpModule;
  2749. exports.Connection = Connection;
  2750. exports.ConnectionBackend = ConnectionBackend;
  2751. exports.XSRFStrategy = XSRFStrategy;
  2752. exports.Request = Request;
  2753. exports.Response = Response;
  2754. exports.QueryEncoder = QueryEncoder;
  2755. exports.URLSearchParams = URLSearchParams;
  2756. exports.VERSION = VERSION;
  2757. exports.ɵe = BrowserJsonp;
  2758. exports.ɵf = Body;
  2759. exports.ɵa = _createDefaultCookieXSRFStrategy;
  2760. exports.ɵb = httpFactory;
  2761. exports.ɵc = jsonpFactory;
  2762. Object.defineProperty(exports, '__esModule', { value: true });
  2763. })));
  2764. //# sourceMappingURL=http.umd.js.map