Front end of the Slack clone application.

http.js 92KB

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