@angular/http
Advanced tools
Comparing version 2.3.0-beta.0 to 2.3.0-beta.1
/** | ||
* @license Angular v2.3.0-beta.0 | ||
* @license Angular v2.3.0-beta.1 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
@@ -160,3 +160,3 @@ * License: MIT | ||
/** @nocollapse */ | ||
MockBackend.ctorParameters = []; | ||
MockBackend.ctorParameters = function () { return []; }; | ||
return MockBackend; | ||
@@ -163,0 +163,0 @@ }()); |
/** | ||
* @license Angular v2.3.0-beta.0 | ||
* @license Angular v2.3.0-beta.1 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
* License: MIT | ||
*/ | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/Observable"),require("@angular/platform-browser")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Observable","@angular/platform-browser"],factory):factory((global.ng=global.ng||{},global.ng.http=global.ng.http||{}),global.ng.core,global.Rx,global.ng.platformBrowser)}(this,function(exports,_angular_core,rxjs_Observable,_angular_platformBrowser){"use strict";function normalizeMethodName(method){if("string"!=typeof method)return method;switch(method.toUpperCase()){case"GET":return exports.RequestMethod.Get;case"POST":return exports.RequestMethod.Post;case"PUT":return exports.RequestMethod.Put;case"DELETE":return exports.RequestMethod.Delete;case"OPTIONS":return exports.RequestMethod.Options;case"HEAD":return exports.RequestMethod.Head;case"PATCH":return exports.RequestMethod.Patch}throw new Error('Invalid request method. The method "'+method+'" is not supported.')}function getResponseURL(xhr){return"responseURL"in xhr?xhr.responseURL:/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())?xhr.getResponseHeader("X-Request-URL"):void 0}function stringToArrayBuffer(input){for(var view=new Uint16Array(input.length),i=0,strLen=input.length;i<strLen;i++)view[i]=input.charCodeAt(i);return view.buffer}/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/Observable"),require("@angular/platform-browser")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Observable","@angular/platform-browser"],factory):factory((global.ng=global.ng||{},global.ng.http=global.ng.http||{}),global.ng.core,global.Rx,global.ng.platformBrowser)}(this,function(exports,_angular_core,rxjs_Observable,_angular_platformBrowser){"use strict";function normalizeMethodName(method){if("string"!=typeof method)return method;switch(method.toUpperCase()){case"GET":return RequestMethod.Get;case"POST":return RequestMethod.Post;case"PUT":return RequestMethod.Put;case"DELETE":return RequestMethod.Delete;case"OPTIONS":return RequestMethod.Options;case"HEAD":return RequestMethod.Head;case"PATCH":return RequestMethod.Patch}throw new Error('Invalid request method. The method "'+method+'" is not supported.')}function getResponseURL(xhr){return"responseURL"in xhr?xhr.responseURL:/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())?xhr.getResponseHeader("X-Request-URL"):void 0}function stringToArrayBuffer(input){for(var view=new Uint16Array(input.length),i=0,strLen=input.length;i<strLen;i++)view[i]=input.charCodeAt(i);return view.buffer}/** | ||
* @license undefined | ||
* Copyright Google Inc. All Rights Reserved. | ||
* * | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* @param {?=} rawParams | ||
* @return {?} | ||
*/ | ||
function paramParser(rawParams){void 0===rawParams&&(rawParams="");var map=new Map;if(rawParams.length>0){var params=rawParams.split("&");params.forEach(function(param){var eqIdx=param.indexOf("="),_a=eqIdx==-1?[param,""]:[param.slice(0,eqIdx),param.slice(eqIdx+1)],key=_a[0],val=_a[1],list=map.get(key)||[];list.push(val),map.set(key,list)})}return map}function standardEncoding(v){return encodeURIComponent(v).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/gi,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%2B/gi,"+").replace(/%3D/gi,"=").replace(/%3F/gi,"?").replace(/%2F/gi,"/")}function _getJsonpConnections(){var w="object"==typeof window?window:{};return null===_jsonpConnections&&(_jsonpConnections=w[JSONP_HOME]={}),_jsonpConnections}function httpRequest(backend,request){return backend.createConnection(request).response}function mergeOptions(defaultOpts,providedOpts,method,url){var newOptions=defaultOpts;return providedOpts?newOptions.merge(new RequestOptions({method:providedOpts.method||method,url:providedOpts.url||url,search:providedOpts.search,headers:providedOpts.headers,body:providedOpts.body,withCredentials:providedOpts.withCredentials,responseType:providedOpts.responseType})):newOptions.merge(new RequestOptions({method:method,url:url}))}function _createDefaultCookieXSRFStrategy(){return new CookieXSRFStrategy}function httpFactory(xhrBackend,requestOptions){return new Http(xhrBackend,requestOptions)}function jsonpFactory(jsonpBackend,requestOptions){return new Jsonp(jsonpBackend,requestOptions)}var BrowserXhr=function(){function BrowserXhr(){}return BrowserXhr.prototype.build=function(){return new XMLHttpRequest},BrowserXhr.decorators=[{type:_angular_core.Injectable}],BrowserXhr.ctorParameters=[],BrowserXhr}();/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
exports.RequestMethod,function(RequestMethod){RequestMethod[RequestMethod.Get=0]="Get",RequestMethod[RequestMethod.Post=1]="Post",RequestMethod[RequestMethod.Put=2]="Put",RequestMethod[RequestMethod.Delete=3]="Delete",RequestMethod[RequestMethod.Options=4]="Options",RequestMethod[RequestMethod.Head=5]="Head",RequestMethod[RequestMethod.Patch=6]="Patch"}(exports.RequestMethod||(exports.RequestMethod={})),exports.ReadyState,function(ReadyState){ReadyState[ReadyState.Unsent=0]="Unsent",ReadyState[ReadyState.Open=1]="Open",ReadyState[ReadyState.HeadersReceived=2]="HeadersReceived",ReadyState[ReadyState.Loading=3]="Loading",ReadyState[ReadyState.Done=4]="Done",ReadyState[ReadyState.Cancelled=5]="Cancelled"}(exports.ReadyState||(exports.ReadyState={})),exports.ResponseType,function(ResponseType){ResponseType[ResponseType.Basic=0]="Basic",ResponseType[ResponseType.Cors=1]="Cors",ResponseType[ResponseType.Default=2]="Default",ResponseType[ResponseType.Error=3]="Error",ResponseType[ResponseType.Opaque=4]="Opaque"}(exports.ResponseType||(exports.ResponseType={}));var ContentType;!function(ContentType){ContentType[ContentType.NONE=0]="NONE",ContentType[ContentType.JSON=1]="JSON",ContentType[ContentType.FORM=2]="FORM",ContentType[ContentType.FORM_DATA=3]="FORM_DATA",ContentType[ContentType.TEXT=4]="TEXT",ContentType[ContentType.BLOB=5]="BLOB",ContentType[ContentType.ARRAY_BUFFER=6]="ARRAY_BUFFER"}(ContentType||(ContentType={})),exports.ResponseContentType,function(ResponseContentType){ResponseContentType[ResponseContentType.Text=0]="Text",ResponseContentType[ResponseContentType.Json=1]="Json",ResponseContentType[ResponseContentType.ArrayBuffer=2]="ArrayBuffer",ResponseContentType[ResponseContentType.Blob=3]="Blob"}(exports.ResponseContentType||(exports.ResponseContentType={}));/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
var Headers=function(){function Headers(headers){var _this=this;if(this._headers=new Map,this._normalizedNames=new Map,headers)return headers instanceof Headers?void headers.forEach(function(values,name){values.forEach(function(value){return _this.append(name,value)})}):void Object.keys(headers).forEach(function(name){var values=Array.isArray(headers[name])?headers[name]:[headers[name]];_this.delete(name),values.forEach(function(value){return _this.append(name,value)})})}return Headers.fromResponseHeaderString=function(headersString){var headers=new Headers;return headersString.split("\n").forEach(function(line){var index=line.indexOf(":");if(index>0){var name_1=line.slice(0,index),value=line.slice(index+1).trim();headers.set(name_1,value)}}),headers},Headers.prototype.append=function(name,value){var values=this.getAll(name);null===values?this.set(name,value):values.push(value)},Headers.prototype.delete=function(name){var lcName=name.toLowerCase();this._normalizedNames.delete(lcName),this._headers.delete(lcName)},Headers.prototype.forEach=function(fn){var _this=this;this._headers.forEach(function(values,lcName){return fn(values,_this._normalizedNames.get(lcName),_this._headers)})},Headers.prototype.get=function(name){var values=this.getAll(name);return null===values?null:values.length>0?values[0]:null},Headers.prototype.has=function(name){return this._headers.has(name.toLowerCase())},Headers.prototype.keys=function(){return Array.from(this._normalizedNames.values())},Headers.prototype.set=function(name,value){Array.isArray(value)?value.length&&this._headers.set(name.toLowerCase(),[value.join(",")]):this._headers.set(name.toLowerCase(),[value]),this.mayBeSetNormalizedName(name)},Headers.prototype.values=function(){return Array.from(this._headers.values())},Headers.prototype.toJSON=function(){var _this=this,serialized={};return this._headers.forEach(function(values,name){var split=[];values.forEach(function(v){return split.push.apply(split,v.split(","))}),serialized[_this._normalizedNames.get(name)]=split}),serialized},Headers.prototype.getAll=function(name){return this.has(name)?this._headers.get(name.toLowerCase()):null},Headers.prototype.entries=function(){throw new Error('"entries" method is not implemented on Headers class')},Headers.prototype.mayBeSetNormalizedName=function(name){var lcName=name.toLowerCase();this._normalizedNames.has(lcName)||this._normalizedNames.set(lcName,name)},Headers}(),__extends$1=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},ResponseOptions=function(){function ResponseOptions(_a){var _b=void 0===_a?{}:_a,body=_b.body,status=_b.status,headers=_b.headers,statusText=_b.statusText,type=_b.type,url=_b.url;this.body=null!=body?body:null,this.status=null!=status?status:null,this.headers=null!=headers?headers:null,this.statusText=null!=statusText?statusText:null,this.type=null!=type?type:null,this.url=null!=url?url:null}return ResponseOptions.prototype.merge=function(options){return new ResponseOptions({body:options&&null!=options.body?options.body:this.body,status:options&&null!=options.status?options.status:this.status,headers:options&&null!=options.headers?options.headers:this.headers,statusText:options&&null!=options.statusText?options.statusText:this.statusText,type:options&&null!=options.type?options.type:this.type,url:options&&null!=options.url?options.url:this.url})},ResponseOptions}(),BaseResponseOptions=function(_super){function BaseResponseOptions(){_super.call(this,{status:200,statusText:"Ok",type:exports.ResponseType.Default,headers:new Headers})}return __extends$1(BaseResponseOptions,_super),BaseResponseOptions.decorators=[{type:_angular_core.Injectable}],BaseResponseOptions.ctorParameters=[],BaseResponseOptions}(ResponseOptions),ConnectionBackend=function(){function ConnectionBackend(){}return ConnectionBackend}(),Connection=function(){function Connection(){}return Connection}(),XSRFStrategy=function(){function XSRFStrategy(){}return XSRFStrategy}(),isSuccess=function(status){return status>=200&&status<300},QueryEncoder=function(){function QueryEncoder(){}return QueryEncoder.prototype.encodeKey=function(k){return standardEncoding(k)},QueryEncoder.prototype.encodeValue=function(v){return standardEncoding(v)},QueryEncoder}(),URLSearchParams=function(){function URLSearchParams(rawParams,queryEncoder){void 0===rawParams&&(rawParams=""),void 0===queryEncoder&&(queryEncoder=new QueryEncoder),this.rawParams=rawParams,this.queryEncoder=queryEncoder,this.paramsMap=paramParser(rawParams)}return URLSearchParams.prototype.clone=function(){var clone=new URLSearchParams("",this.queryEncoder);return clone.appendAll(this),clone},URLSearchParams.prototype.has=function(param){return this.paramsMap.has(param)},URLSearchParams.prototype.get=function(param){var storedParam=this.paramsMap.get(param);return Array.isArray(storedParam)?storedParam[0]:null},URLSearchParams.prototype.getAll=function(param){return this.paramsMap.get(param)||[]},URLSearchParams.prototype.set=function(param,val){if(void 0===val||null===val)return void this.delete(param);var list=this.paramsMap.get(param)||[];list.length=0,list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.setAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var list=_this.paramsMap.get(param)||[];list.length=0,list.push(value[0]),_this.paramsMap.set(param,list)})},URLSearchParams.prototype.append=function(param,val){if(void 0!==val&&null!==val){var list=this.paramsMap.get(param)||[];list.push(val),this.paramsMap.set(param,list)}},URLSearchParams.prototype.appendAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){for(var list=_this.paramsMap.get(param)||[],i=0;i<value.length;++i)list.push(value[i]);_this.paramsMap.set(param,list)})},URLSearchParams.prototype.replaceAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var list=_this.paramsMap.get(param)||[];list.length=0;for(var i=0;i<value.length;++i)list.push(value[i]);_this.paramsMap.set(param,list)})},URLSearchParams.prototype.toString=function(){var _this=this,paramsList=[];return this.paramsMap.forEach(function(values,k){values.forEach(function(v){return paramsList.push(_this.queryEncoder.encodeKey(k)+"="+_this.queryEncoder.encodeValue(v))})}),paramsList.join("&")},URLSearchParams.prototype.delete=function(param){this.paramsMap.delete(param)},URLSearchParams}(),Body=function(){function Body(){}return Body.prototype.json=function(){return"string"==typeof this._body?JSON.parse(this._body):this._body instanceof ArrayBuffer?JSON.parse(this.text()):this._body},Body.prototype.text=function(){return this._body instanceof URLSearchParams?this._body.toString():this._body instanceof ArrayBuffer?String.fromCharCode.apply(null,new Uint16Array(this._body)):null===this._body?"":"object"==typeof this._body?JSON.stringify(this._body,null,2):this._body.toString()},Body.prototype.arrayBuffer=function(){return this._body instanceof ArrayBuffer?this._body:stringToArrayBuffer(this.text())},Body.prototype.blob=function(){if(this._body instanceof Blob)return this._body;if(this._body instanceof ArrayBuffer)return new Blob([this._body]);throw new Error("The request body isn't either a blob or an array buffer")},Body}(),__extends$2=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Response=function(_super){function Response(responseOptions){_super.call(this),this._body=responseOptions.body,this.status=responseOptions.status,this.ok=this.status>=200&&this.status<=299,this.statusText=responseOptions.statusText,this.headers=responseOptions.headers,this.type=responseOptions.type,this.url=responseOptions.url}return __extends$2(Response,_super),Response.prototype.toString=function(){return"Response with status: "+this.status+" "+this.statusText+" for URL: "+this.url},Response}(Body),_nextRequestId=0,JSONP_HOME="__ng_jsonp__",_jsonpConnections=null,BrowserJsonp=function(){function BrowserJsonp(){}return BrowserJsonp.prototype.build=function(url){var node=document.createElement("script");return node.src=url,node},BrowserJsonp.prototype.nextRequestID=function(){return"__req"+_nextRequestId++},BrowserJsonp.prototype.requestCallback=function(id){return JSONP_HOME+"."+id+".finished"},BrowserJsonp.prototype.exposeConnection=function(id,connection){var connections=_getJsonpConnections();connections[id]=connection},BrowserJsonp.prototype.removeConnection=function(id){var connections=_getJsonpConnections();connections[id]=null},BrowserJsonp.prototype.send=function(node){document.body.appendChild(node)},BrowserJsonp.prototype.cleanup=function(node){node.parentNode&&node.parentNode.removeChild(node)},BrowserJsonp.decorators=[{type:_angular_core.Injectable}],BrowserJsonp.ctorParameters=[],BrowserJsonp}(),__extends=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},JSONP_ERR_NO_CALLBACK="JSONP injected script did not invoke callback.",JSONP_ERR_WRONG_METHOD="JSONP requests must use GET request method.",JSONPConnection=function(){function JSONPConnection(){}return JSONPConnection}(),JSONPConnection_=function(_super){function JSONPConnection_(req,_dom,baseResponseOptions){var _this=this;if(_super.call(this),this._dom=_dom,this.baseResponseOptions=baseResponseOptions,this._finished=!1,req.method!==exports.RequestMethod.Get)throw new TypeError(JSONP_ERR_WRONG_METHOD);this.request=req,this.response=new rxjs_Observable.Observable(function(responseObserver){_this.readyState=exports.ReadyState.Loading;var id=_this._id=_dom.nextRequestID();_dom.exposeConnection(id,_this);var callback=_dom.requestCallback(_this._id),url=req.url;url.indexOf("=JSONP_CALLBACK&")>-1?url=url.replace("=JSONP_CALLBACK&","="+callback+"&"):url.lastIndexOf("=JSONP_CALLBACK")===url.length-"=JSONP_CALLBACK".length&&(url=url.substring(0,url.length-"=JSONP_CALLBACK".length)+("="+callback));var script=_this._script=_dom.build(url),onLoad=function(event){if(_this.readyState!==exports.ReadyState.Cancelled){if(_this.readyState=exports.ReadyState.Done,_dom.cleanup(script),!_this._finished){var responseOptions_1=new ResponseOptions({body:JSONP_ERR_NO_CALLBACK,type:exports.ResponseType.Error,url:url});return baseResponseOptions&&(responseOptions_1=baseResponseOptions.merge(responseOptions_1)),void responseObserver.error(new Response(responseOptions_1))}var responseOptions=new ResponseOptions({body:_this._responseData,url:url});_this.baseResponseOptions&&(responseOptions=_this.baseResponseOptions.merge(responseOptions)),responseObserver.next(new Response(responseOptions)),responseObserver.complete()}},onError=function(error){if(_this.readyState!==exports.ReadyState.Cancelled){_this.readyState=exports.ReadyState.Done,_dom.cleanup(script);var responseOptions=new ResponseOptions({body:error.message,type:exports.ResponseType.Error});baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))}};return script.addEventListener("load",onLoad),script.addEventListener("error",onError),_dom.send(script),function(){_this.readyState=exports.ReadyState.Cancelled,script.removeEventListener("load",onLoad),script.removeEventListener("error",onError),_this._dom.cleanup(script)}})}return __extends(JSONPConnection_,_super),JSONPConnection_.prototype.finished=function(data){this._finished=!0,this._dom.removeConnection(this._id),this.readyState!==exports.ReadyState.Cancelled&&(this._responseData=data)},JSONPConnection_}(JSONPConnection),JSONPBackend=function(_super){function JSONPBackend(){_super.apply(this,arguments)}return __extends(JSONPBackend,_super),JSONPBackend}(ConnectionBackend),JSONPBackend_=function(_super){function JSONPBackend_(_browserJSONP,_baseResponseOptions){_super.call(this),this._browserJSONP=_browserJSONP,this._baseResponseOptions=_baseResponseOptions}return __extends(JSONPBackend_,_super),JSONPBackend_.prototype.createConnection=function(request){return new JSONPConnection_(request,this._browserJSONP,this._baseResponseOptions)},JSONPBackend_.decorators=[{type:_angular_core.Injectable}],JSONPBackend_.ctorParameters=[{type:BrowserJsonp},{type:ResponseOptions}],JSONPBackend_}(JSONPBackend),XSSI_PREFIX=/^\)\]\}',?\n/,XHRConnection=function(){function XHRConnection(req,browserXHR,baseResponseOptions){var _this=this;this.request=req,this.response=new rxjs_Observable.Observable(function(responseObserver){var _xhr=browserXHR.build();_xhr.open(exports.RequestMethod[req.method].toUpperCase(),req.url),null!=req.withCredentials&&(_xhr.withCredentials=req.withCredentials);var onLoad=function(){var status=1223===_xhr.status?204:_xhr.status,body=null;204!==status&&(body=null==_xhr.response?_xhr.responseText:_xhr.response,"string"==typeof body&&(body=body.replace(XSSI_PREFIX,""))),0===status&&(status=body?200:0);var headers=Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders()),url=getResponseURL(_xhr)||req.url,statusText=_xhr.statusText||"OK",responseOptions=new ResponseOptions({body:body,status:status,headers:headers,statusText:statusText,url:url});null!=baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions));var response=new Response(responseOptions);return response.ok=isSuccess(status),response.ok?(responseObserver.next(response),void responseObserver.complete()):void responseObserver.error(response)},onError=function(err){var responseOptions=new ResponseOptions({body:err,type:exports.ResponseType.Error,status:_xhr.status,statusText:_xhr.statusText});null!=baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))};if(_this.setDetectedContentType(req,_xhr),null!=req.headers&&req.headers.forEach(function(values,name){return _xhr.setRequestHeader(name,values.join(","))}),null!=req.responseType&&null!=_xhr.responseType)switch(req.responseType){case exports.ResponseContentType.ArrayBuffer:_xhr.responseType="arraybuffer";break;case exports.ResponseContentType.Json:_xhr.responseType="json";break;case exports.ResponseContentType.Text:_xhr.responseType="text";break;case exports.ResponseContentType.Blob:_xhr.responseType="blob";break;default:throw new Error("The selected responseType is not supported")}return _xhr.addEventListener("load",onLoad),_xhr.addEventListener("error",onError),_xhr.send(_this.request.getBody()),function(){_xhr.removeEventListener("load",onLoad),_xhr.removeEventListener("error",onError),_xhr.abort()}})}return XHRConnection.prototype.setDetectedContentType=function(req,_xhr){if(null==req.headers||null==req.headers.get("Content-Type"))switch(req.contentType){case ContentType.NONE:break;case ContentType.JSON:_xhr.setRequestHeader("content-type","application/json");break;case ContentType.FORM:_xhr.setRequestHeader("content-type","application/x-www-form-urlencoded;charset=UTF-8");break;case ContentType.TEXT:_xhr.setRequestHeader("content-type","text/plain");break;case ContentType.BLOB:var blob=req.blob();blob.type&&_xhr.setRequestHeader("content-type",blob.type)}},XHRConnection}(),CookieXSRFStrategy=function(){function CookieXSRFStrategy(_cookieName,_headerName){void 0===_cookieName&&(_cookieName="XSRF-TOKEN"),void 0===_headerName&&(_headerName="X-XSRF-TOKEN"),this._cookieName=_cookieName,this._headerName=_headerName}return CookieXSRFStrategy.prototype.configureRequest=function(req){var xsrfToken=_angular_platformBrowser.__platform_browser_private__.getDOM().getCookie(this._cookieName);xsrfToken&&req.headers.set(this._headerName,xsrfToken)},CookieXSRFStrategy}(),XHRBackend=function(){function XHRBackend(_browserXHR,_baseResponseOptions,_xsrfStrategy){this._browserXHR=_browserXHR,this._baseResponseOptions=_baseResponseOptions,this._xsrfStrategy=_xsrfStrategy}return XHRBackend.prototype.createConnection=function(request){return this._xsrfStrategy.configureRequest(request),new XHRConnection(request,this._browserXHR,this._baseResponseOptions)},XHRBackend.decorators=[{type:_angular_core.Injectable}],XHRBackend.ctorParameters=[{type:BrowserXhr},{type:ResponseOptions},{type:XSRFStrategy}],XHRBackend}(),__extends$3=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},RequestOptions=function(){function RequestOptions(_a){var _b=void 0===_a?{}:_a,method=_b.method,headers=_b.headers,body=_b.body,url=_b.url,search=_b.search,withCredentials=_b.withCredentials,responseType=_b.responseType;this.method=null!=method?normalizeMethodName(method):null,this.headers=null!=headers?headers:null,this.body=null!=body?body:null,this.url=null!=url?url:null,this.search=null!=search?"string"==typeof search?new URLSearchParams(search):search:null,this.withCredentials=null!=withCredentials?withCredentials:null,this.responseType=null!=responseType?responseType:null}return RequestOptions.prototype.merge=function(options){return new RequestOptions({method:options&&null!=options.method?options.method:this.method,headers:options&&null!=options.headers?options.headers:this.headers,body:options&&null!=options.body?options.body:this.body,url:options&&null!=options.url?options.url:this.url,search:options&&null!=options.search?"string"==typeof options.search?new URLSearchParams(options.search):options.search.clone():this.search,withCredentials:options&&null!=options.withCredentials?options.withCredentials:this.withCredentials,responseType:options&&null!=options.responseType?options.responseType:this.responseType})},RequestOptions}(),BaseRequestOptions=function(_super){function BaseRequestOptions(){_super.call(this,{method:exports.RequestMethod.Get,headers:new Headers})}return __extends$3(BaseRequestOptions,_super),BaseRequestOptions.decorators=[{type:_angular_core.Injectable}],BaseRequestOptions.ctorParameters=[],BaseRequestOptions}(RequestOptions),__extends$5=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Request=function(_super){function Request(requestOptions){_super.call(this);var url=requestOptions.url;if(this.url=requestOptions.url,requestOptions.search){var search=requestOptions.search.toString();if(search.length>0){var prefix="?";this.url.indexOf("?")!=-1&&(prefix="&"==this.url[this.url.length-1]?"":"&"),this.url=url+prefix+search}}this._body=requestOptions.body,this.method=normalizeMethodName(requestOptions.method),this.headers=new Headers(requestOptions.headers),this.contentType=this.detectContentType(),this.withCredentials=requestOptions.withCredentials,this.responseType=requestOptions.responseType}return __extends$5(Request,_super),Request.prototype.detectContentType=function(){switch(this.headers.get("content-type")){case"application/json":return ContentType.JSON;case"application/x-www-form-urlencoded":return ContentType.FORM;case"multipart/form-data":return ContentType.FORM_DATA;case"text/plain":case"text/html":return ContentType.TEXT;case"application/octet-stream":return ContentType.BLOB;default:return this.detectContentTypeFromBody()}},Request.prototype.detectContentTypeFromBody=function(){return null==this._body?ContentType.NONE:this._body instanceof URLSearchParams?ContentType.FORM:this._body instanceof FormData?ContentType.FORM_DATA:this._body instanceof Blob$1?ContentType.BLOB:this._body instanceof ArrayBuffer$1?ContentType.ARRAY_BUFFER:this._body&&"object"==typeof this._body?ContentType.JSON:ContentType.TEXT},Request.prototype.getBody=function(){switch(this.contentType){case ContentType.JSON:return this.text();case ContentType.FORM:return this.text();case ContentType.FORM_DATA:return this._body;case ContentType.TEXT:return this.text();case ContentType.BLOB:return this.blob();case ContentType.ARRAY_BUFFER:return this.arrayBuffer();default:return null}},Request}(Body),noop=function(){},w="object"==typeof window?window:noop,FormData=w.FormData||noop,Blob$1=w.Blob||noop,ArrayBuffer$1=w.ArrayBuffer||noop,__extends$4=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Http=function(){function Http(_backend,_defaultOptions){this._backend=_backend,this._defaultOptions=_defaultOptions}return Http.prototype.request=function(url,options){var responseObservable;if("string"==typeof url)responseObservable=httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)));else{if(!(url instanceof Request))throw new Error("First argument must be a url string or Request instance.");responseObservable=httpRequest(this._backend,url)}return responseObservable},Http.prototype.get=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)))},Http.prototype.post=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Post,url)))},Http.prototype.put=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Put,url)))},Http.prototype.delete=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Delete,url)))},Http.prototype.patch=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Patch,url)))},Http.prototype.head=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Head,url)))},Http.prototype.options=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Options,url)))},Http.decorators=[{type:_angular_core.Injectable}],Http.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}],Http}(),Jsonp=function(_super){function Jsonp(backend,defaultOptions){_super.call(this,backend,defaultOptions)}return __extends$4(Jsonp,_super),Jsonp.prototype.request=function(url,options){var responseObservable;if("string"==typeof url&&(url=new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url))),!(url instanceof Request))throw new Error("First argument must be a url string or Request instance.");if(url.method!==exports.RequestMethod.Get)throw new Error("JSONP requests must use GET request method.");return responseObservable=httpRequest(this._backend,url)},Jsonp.decorators=[{type:_angular_core.Injectable}],Jsonp.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}],Jsonp}(Http),HttpModule=function(){function HttpModule(){}return HttpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:[{provide:Http,useFactory:httpFactory,deps:[XHRBackend,RequestOptions]},BrowserXhr,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},XHRBackend,{provide:XSRFStrategy,useFactory:_createDefaultCookieXSRFStrategy}]}]}],HttpModule.ctorParameters=[],HttpModule}(),JsonpModule=function(){function JsonpModule(){}return JsonpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:[{provide:Jsonp,useFactory:jsonpFactory,deps:[JSONPBackend,RequestOptions]},BrowserJsonp,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},{provide:JSONPBackend,useClass:JSONPBackend_}]}]}],JsonpModule.ctorParameters=[],JsonpModule}();exports.BrowserXhr=BrowserXhr,exports.JSONPBackend=JSONPBackend,exports.JSONPConnection=JSONPConnection,exports.CookieXSRFStrategy=CookieXSRFStrategy,exports.XHRBackend=XHRBackend,exports.XHRConnection=XHRConnection,exports.BaseRequestOptions=BaseRequestOptions,exports.RequestOptions=RequestOptions,exports.BaseResponseOptions=BaseResponseOptions,exports.ResponseOptions=ResponseOptions,exports.Headers=Headers,exports.Http=Http,exports.Jsonp=Jsonp,exports.HttpModule=HttpModule,exports.JsonpModule=JsonpModule,exports.Connection=Connection,exports.ConnectionBackend=ConnectionBackend,exports.XSRFStrategy=XSRFStrategy,exports.Request=Request,exports.Response=Response,exports.QueryEncoder=QueryEncoder,exports.URLSearchParams=URLSearchParams}); | ||
function paramParser(rawParams){void 0===rawParams&&(rawParams="");var map=new Map;if(rawParams.length>0){var params=rawParams.split("&");params.forEach(function(param){var eqIdx=param.indexOf("="),_a=eqIdx==-1?[param,""]:[param.slice(0,eqIdx),param.slice(eqIdx+1)],key=_a[0],val=_a[1],list=map.get(key)||[];list.push(val),map.set(key,list)})}return map}function standardEncoding(v){return encodeURIComponent(v).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/gi,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%2B/gi,"+").replace(/%3D/gi,"=").replace(/%3F/gi,"?").replace(/%2F/gi,"/")}function _getJsonpConnections(){var w="object"==typeof window?window:{};return null===_jsonpConnections&&(_jsonpConnections=w[JSONP_HOME]={}),_jsonpConnections}function httpRequest(backend,request){return backend.createConnection(request).response}function mergeOptions(defaultOpts,providedOpts,method,url){var newOptions=defaultOpts;return providedOpts?newOptions.merge(new RequestOptions({method:providedOpts.method||method,url:providedOpts.url||url,search:providedOpts.search,headers:providedOpts.headers,body:providedOpts.body,withCredentials:providedOpts.withCredentials,responseType:providedOpts.responseType})):newOptions.merge(new RequestOptions({method:method,url:url}))}function _createDefaultCookieXSRFStrategy(){return new CookieXSRFStrategy}function httpFactory(xhrBackend,requestOptions){return new Http(xhrBackend,requestOptions)}function jsonpFactory(jsonpBackend,requestOptions){return new Jsonp(jsonpBackend,requestOptions)}var BrowserXhr=function(){function BrowserXhr(){}return BrowserXhr.prototype.build=function(){return new XMLHttpRequest},BrowserXhr.decorators=[{type:_angular_core.Injectable}],BrowserXhr.ctorParameters=function(){return[]},BrowserXhr}(),RequestMethod={};RequestMethod.Get=0,RequestMethod.Post=1,RequestMethod.Put=2,RequestMethod.Delete=3,RequestMethod.Options=4,RequestMethod.Head=5,RequestMethod.Patch=6,RequestMethod[RequestMethod.Get]="Get",RequestMethod[RequestMethod.Post]="Post",RequestMethod[RequestMethod.Put]="Put",RequestMethod[RequestMethod.Delete]="Delete",RequestMethod[RequestMethod.Options]="Options",RequestMethod[RequestMethod.Head]="Head",RequestMethod[RequestMethod.Patch]="Patch";var ReadyState={};ReadyState.Unsent=0,ReadyState.Open=1,ReadyState.HeadersReceived=2,ReadyState.Loading=3,ReadyState.Done=4,ReadyState.Cancelled=5,ReadyState[ReadyState.Unsent]="Unsent",ReadyState[ReadyState.Open]="Open",ReadyState[ReadyState.HeadersReceived]="HeadersReceived",ReadyState[ReadyState.Loading]="Loading",ReadyState[ReadyState.Done]="Done",ReadyState[ReadyState.Cancelled]="Cancelled";var ResponseType={};ResponseType.Basic=0,ResponseType.Cors=1,ResponseType.Default=2,ResponseType.Error=3,ResponseType.Opaque=4,ResponseType[ResponseType.Basic]="Basic",ResponseType[ResponseType.Cors]="Cors",ResponseType[ResponseType.Default]="Default",ResponseType[ResponseType.Error]="Error",ResponseType[ResponseType.Opaque]="Opaque";var ContentType={};ContentType.NONE=0,ContentType.JSON=1,ContentType.FORM=2,ContentType.FORM_DATA=3,ContentType.TEXT=4,ContentType.BLOB=5,ContentType.ARRAY_BUFFER=6,ContentType[ContentType.NONE]="NONE",ContentType[ContentType.JSON]="JSON",ContentType[ContentType.FORM]="FORM",ContentType[ContentType.FORM_DATA]="FORM_DATA",ContentType[ContentType.TEXT]="TEXT",ContentType[ContentType.BLOB]="BLOB",ContentType[ContentType.ARRAY_BUFFER]="ARRAY_BUFFER";var ResponseContentType={};ResponseContentType.Text=0,ResponseContentType.Json=1,ResponseContentType.ArrayBuffer=2,ResponseContentType.Blob=3,ResponseContentType[ResponseContentType.Text]="Text",ResponseContentType[ResponseContentType.Json]="Json",ResponseContentType[ResponseContentType.ArrayBuffer]="ArrayBuffer",ResponseContentType[ResponseContentType.Blob]="Blob";var Headers=function(){function Headers(headers){var _this=this;if(this._headers=new Map,this._normalizedNames=new Map,headers)return headers instanceof Headers?void headers.forEach(function(values,name){values.forEach(function(value){return _this.append(name,value)})}):void Object.keys(headers).forEach(function(name){var values=Array.isArray(headers[name])?headers[name]:[headers[name]];_this.delete(name),values.forEach(function(value){return _this.append(name,value)})})}return Headers.fromResponseHeaderString=function(headersString){var headers=new Headers;return headersString.split("\n").forEach(function(line){var index=line.indexOf(":");if(index>0){var name_1=line.slice(0,index),value=line.slice(index+1).trim();headers.set(name_1,value)}}),headers},Headers.prototype.append=function(name,value){var values=this.getAll(name);null===values?this.set(name,value):values.push(value)},Headers.prototype.delete=function(name){var lcName=name.toLowerCase();this._normalizedNames.delete(lcName),this._headers.delete(lcName)},Headers.prototype.forEach=function(fn){var _this=this;this._headers.forEach(function(values,lcName){return fn(values,_this._normalizedNames.get(lcName),_this._headers)})},Headers.prototype.get=function(name){var values=this.getAll(name);return null===values?null:values.length>0?values[0]:null},Headers.prototype.has=function(name){return this._headers.has(name.toLowerCase())},Headers.prototype.keys=function(){return Array.from(this._normalizedNames.values())},Headers.prototype.set=function(name,value){Array.isArray(value)?value.length&&this._headers.set(name.toLowerCase(),[value.join(",")]):this._headers.set(name.toLowerCase(),[value]),this.mayBeSetNormalizedName(name)},Headers.prototype.values=function(){return Array.from(this._headers.values())},Headers.prototype.toJSON=function(){var _this=this,serialized={};return this._headers.forEach(function(values,name){var split=[];values.forEach(function(v){return split.push.apply(split,v.split(","))}),serialized[_this._normalizedNames.get(name)]=split}),serialized},Headers.prototype.getAll=function(name){return this.has(name)?this._headers.get(name.toLowerCase()):null},Headers.prototype.entries=function(){throw new Error('"entries" method is not implemented on Headers class')},Headers.prototype.mayBeSetNormalizedName=function(name){var lcName=name.toLowerCase();this._normalizedNames.has(lcName)||this._normalizedNames.set(lcName,name)},Headers}(),__extends$1=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},ResponseOptions=function(){function ResponseOptions(_a){var _b=void 0===_a?{}:_a,body=_b.body,status=_b.status,headers=_b.headers,statusText=_b.statusText,type=_b.type,url=_b.url;this.body=null!=body?body:null,this.status=null!=status?status:null,this.headers=null!=headers?headers:null,this.statusText=null!=statusText?statusText:null,this.type=null!=type?type:null,this.url=null!=url?url:null}return ResponseOptions.prototype.merge=function(options){return new ResponseOptions({body:options&&null!=options.body?options.body:this.body,status:options&&null!=options.status?options.status:this.status,headers:options&&null!=options.headers?options.headers:this.headers,statusText:options&&null!=options.statusText?options.statusText:this.statusText,type:options&&null!=options.type?options.type:this.type,url:options&&null!=options.url?options.url:this.url})},ResponseOptions}(),BaseResponseOptions=function(_super){function BaseResponseOptions(){_super.call(this,{status:200,statusText:"Ok",type:ResponseType.Default,headers:new Headers})}return __extends$1(BaseResponseOptions,_super),BaseResponseOptions.decorators=[{type:_angular_core.Injectable}],BaseResponseOptions.ctorParameters=function(){return[]},BaseResponseOptions}(ResponseOptions),ConnectionBackend=function(){function ConnectionBackend(){}return ConnectionBackend.prototype.createConnection=function(request){},ConnectionBackend}(),Connection=function(){function Connection(){}return Connection}(),XSRFStrategy=function(){function XSRFStrategy(){}return XSRFStrategy.prototype.configureRequest=function(req){},XSRFStrategy}(),isSuccess=function(status){return status>=200&&status<300},QueryEncoder=function(){function QueryEncoder(){}return QueryEncoder.prototype.encodeKey=function(k){return standardEncoding(k)},QueryEncoder.prototype.encodeValue=function(v){return standardEncoding(v)},QueryEncoder}(),URLSearchParams=function(){function URLSearchParams(rawParams,queryEncoder){void 0===rawParams&&(rawParams=""),void 0===queryEncoder&&(queryEncoder=new QueryEncoder),this.rawParams=rawParams,this.queryEncoder=queryEncoder,this.paramsMap=paramParser(rawParams)}return URLSearchParams.prototype.clone=function(){var clone=new URLSearchParams("",this.queryEncoder);return clone.appendAll(this),clone},URLSearchParams.prototype.has=function(param){return this.paramsMap.has(param)},URLSearchParams.prototype.get=function(param){var storedParam=this.paramsMap.get(param);return Array.isArray(storedParam)?storedParam[0]:null},URLSearchParams.prototype.getAll=function(param){return this.paramsMap.get(param)||[]},URLSearchParams.prototype.set=function(param,val){if(void 0===val||null===val)return void this.delete(param);var list=this.paramsMap.get(param)||[];list.length=0,list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.setAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var list=_this.paramsMap.get(param)||[];list.length=0,list.push(value[0]),_this.paramsMap.set(param,list)})},URLSearchParams.prototype.append=function(param,val){if(void 0!==val&&null!==val){var list=this.paramsMap.get(param)||[];list.push(val),this.paramsMap.set(param,list)}},URLSearchParams.prototype.appendAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){for(var list=_this.paramsMap.get(param)||[],i=0;i<value.length;++i)list.push(value[i]);_this.paramsMap.set(param,list)})},URLSearchParams.prototype.replaceAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var list=_this.paramsMap.get(param)||[];list.length=0;for(var i=0;i<value.length;++i)list.push(value[i]);_this.paramsMap.set(param,list)})},URLSearchParams.prototype.toString=function(){var _this=this,paramsList=[];return this.paramsMap.forEach(function(values,k){values.forEach(function(v){return paramsList.push(_this.queryEncoder.encodeKey(k)+"="+_this.queryEncoder.encodeValue(v))})}),paramsList.join("&")},URLSearchParams.prototype.delete=function(param){this.paramsMap.delete(param)},URLSearchParams}(),Body=function(){function Body(){}return Body.prototype.json=function(){return"string"==typeof this._body?JSON.parse(this._body):this._body instanceof ArrayBuffer?JSON.parse(this.text()):this._body},Body.prototype.text=function(){return this._body instanceof URLSearchParams?this._body.toString():this._body instanceof ArrayBuffer?String.fromCharCode.apply(null,new Uint16Array(this._body)):null===this._body?"":"object"==typeof this._body?JSON.stringify(this._body,null,2):this._body.toString()},Body.prototype.arrayBuffer=function(){return this._body instanceof ArrayBuffer?this._body:stringToArrayBuffer(this.text())},Body.prototype.blob=function(){if(this._body instanceof Blob)return this._body;if(this._body instanceof ArrayBuffer)return new Blob([this._body]);throw new Error("The request body isn't either a blob or an array buffer")},Body}(),__extends$2=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Response=function(_super){function Response(responseOptions){_super.call(this),this._body=responseOptions.body,this.status=responseOptions.status,this.ok=this.status>=200&&this.status<=299,this.statusText=responseOptions.statusText,this.headers=responseOptions.headers,this.type=responseOptions.type,this.url=responseOptions.url}return __extends$2(Response,_super),Response.prototype.toString=function(){return"Response with status: "+this.status+" "+this.statusText+" for URL: "+this.url},Response}(Body),_nextRequestId=0,JSONP_HOME="__ng_jsonp__",_jsonpConnections=null,BrowserJsonp=function(){function BrowserJsonp(){}return BrowserJsonp.prototype.build=function(url){var node=document.createElement("script");return node.src=url,node},BrowserJsonp.prototype.nextRequestID=function(){return"__req"+_nextRequestId++},BrowserJsonp.prototype.requestCallback=function(id){return JSONP_HOME+"."+id+".finished"},BrowserJsonp.prototype.exposeConnection=function(id,connection){var connections=_getJsonpConnections();connections[id]=connection},BrowserJsonp.prototype.removeConnection=function(id){var connections=_getJsonpConnections();connections[id]=null},BrowserJsonp.prototype.send=function(node){document.body.appendChild(node)},BrowserJsonp.prototype.cleanup=function(node){node.parentNode&&node.parentNode.removeChild(node)},BrowserJsonp.decorators=[{type:_angular_core.Injectable}],BrowserJsonp.ctorParameters=function(){return[]},BrowserJsonp}(),__extends=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},JSONP_ERR_NO_CALLBACK="JSONP injected script did not invoke callback.",JSONP_ERR_WRONG_METHOD="JSONP requests must use GET request method.",JSONPConnection=function(){function JSONPConnection(){}return JSONPConnection.prototype.finished=function(data){},JSONPConnection}(),JSONPConnection_=function(_super){function JSONPConnection_(req,_dom,baseResponseOptions){var _this=this;if(_super.call(this),this._dom=_dom,this.baseResponseOptions=baseResponseOptions,this._finished=!1,req.method!==RequestMethod.Get)throw new TypeError(JSONP_ERR_WRONG_METHOD);this.request=req,this.response=new rxjs_Observable.Observable(function(responseObserver){_this.readyState=ReadyState.Loading;var id=_this._id=_dom.nextRequestID();_dom.exposeConnection(id,_this);var callback=_dom.requestCallback(_this._id),url=req.url;url.indexOf("=JSONP_CALLBACK&")>-1?url=url.replace("=JSONP_CALLBACK&","="+callback+"&"):url.lastIndexOf("=JSONP_CALLBACK")===url.length-"=JSONP_CALLBACK".length&&(url=url.substring(0,url.length-"=JSONP_CALLBACK".length)+("="+callback));var script=_this._script=_dom.build(url),onLoad=function(event){if(_this.readyState!==ReadyState.Cancelled){if(_this.readyState=ReadyState.Done,_dom.cleanup(script),!_this._finished){var responseOptions_1=new ResponseOptions({body:JSONP_ERR_NO_CALLBACK,type:ResponseType.Error,url:url});return baseResponseOptions&&(responseOptions_1=baseResponseOptions.merge(responseOptions_1)),void responseObserver.error(new Response(responseOptions_1))}var responseOptions=new ResponseOptions({body:_this._responseData,url:url});_this.baseResponseOptions&&(responseOptions=_this.baseResponseOptions.merge(responseOptions)),responseObserver.next(new Response(responseOptions)),responseObserver.complete()}},onError=function(error){if(_this.readyState!==ReadyState.Cancelled){_this.readyState=ReadyState.Done,_dom.cleanup(script);var responseOptions=new ResponseOptions({body:error.message,type:ResponseType.Error});baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))}};return script.addEventListener("load",onLoad),script.addEventListener("error",onError),_dom.send(script),function(){_this.readyState=ReadyState.Cancelled,script.removeEventListener("load",onLoad),script.removeEventListener("error",onError),_this._dom.cleanup(script)}})}return __extends(JSONPConnection_,_super),JSONPConnection_.prototype.finished=function(data){this._finished=!0,this._dom.removeConnection(this._id),this.readyState!==ReadyState.Cancelled&&(this._responseData=data)},JSONPConnection_}(JSONPConnection),JSONPBackend=function(_super){function JSONPBackend(){_super.apply(this,arguments)}return __extends(JSONPBackend,_super),JSONPBackend}(ConnectionBackend),JSONPBackend_=function(_super){function JSONPBackend_(_browserJSONP,_baseResponseOptions){_super.call(this),this._browserJSONP=_browserJSONP,this._baseResponseOptions=_baseResponseOptions}return __extends(JSONPBackend_,_super),JSONPBackend_.prototype.createConnection=function(request){return new JSONPConnection_(request,this._browserJSONP,this._baseResponseOptions)},JSONPBackend_.decorators=[{type:_angular_core.Injectable}],JSONPBackend_.ctorParameters=function(){return[{type:BrowserJsonp},{type:ResponseOptions}]},JSONPBackend_}(JSONPBackend),XSSI_PREFIX=/^\)\]\}',?\n/,XHRConnection=function(){function XHRConnection(req,browserXHR,baseResponseOptions){var _this=this;this.request=req,this.response=new rxjs_Observable.Observable(function(responseObserver){var _xhr=browserXHR.build();_xhr.open(RequestMethod[req.method].toUpperCase(),req.url),null!=req.withCredentials&&(_xhr.withCredentials=req.withCredentials);var onLoad=function(){var status=1223===_xhr.status?204:_xhr.status,body=null;204!==status&&(body=null==_xhr.response?_xhr.responseText:_xhr.response,"string"==typeof body&&(body=body.replace(XSSI_PREFIX,""))),0===status&&(status=body?200:0);var headers=Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders()),url=getResponseURL(_xhr)||req.url,statusText=_xhr.statusText||"OK",responseOptions=new ResponseOptions({body:body,status:status,headers:headers,statusText:statusText,url:url});null!=baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions));var response=new Response(responseOptions);return response.ok=isSuccess(status),response.ok?(responseObserver.next(response),void responseObserver.complete()):void responseObserver.error(response)},onError=function(err){var responseOptions=new ResponseOptions({body:err,type:ResponseType.Error,status:_xhr.status,statusText:_xhr.statusText});null!=baseResponseOptions&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))};if(_this.setDetectedContentType(req,_xhr),null!=req.headers&&req.headers.forEach(function(values,name){return _xhr.setRequestHeader(name,values.join(","))}),null!=req.responseType&&null!=_xhr.responseType)switch(req.responseType){case ResponseContentType.ArrayBuffer:_xhr.responseType="arraybuffer";break;case ResponseContentType.Json:_xhr.responseType="json";break;case ResponseContentType.Text:_xhr.responseType="text";break;case ResponseContentType.Blob:_xhr.responseType="blob";break;default:throw new Error("The selected responseType is not supported")}return _xhr.addEventListener("load",onLoad),_xhr.addEventListener("error",onError),_xhr.send(_this.request.getBody()),function(){_xhr.removeEventListener("load",onLoad),_xhr.removeEventListener("error",onError),_xhr.abort()}})}return XHRConnection.prototype.setDetectedContentType=function(req,_xhr){if(null==req.headers||null==req.headers.get("Content-Type"))switch(req.contentType){case ContentType.NONE:break;case ContentType.JSON:_xhr.setRequestHeader("content-type","application/json");break;case ContentType.FORM:_xhr.setRequestHeader("content-type","application/x-www-form-urlencoded;charset=UTF-8");break;case ContentType.TEXT:_xhr.setRequestHeader("content-type","text/plain");break;case ContentType.BLOB:var blob=req.blob();blob.type&&_xhr.setRequestHeader("content-type",blob.type)}},XHRConnection}(),CookieXSRFStrategy=function(){function CookieXSRFStrategy(_cookieName,_headerName){void 0===_cookieName&&(_cookieName="XSRF-TOKEN"),void 0===_headerName&&(_headerName="X-XSRF-TOKEN"),this._cookieName=_cookieName,this._headerName=_headerName}return CookieXSRFStrategy.prototype.configureRequest=function(req){var xsrfToken=_angular_platformBrowser.__platform_browser_private__.getDOM().getCookie(this._cookieName);xsrfToken&&req.headers.set(this._headerName,xsrfToken)},CookieXSRFStrategy}(),XHRBackend=function(){function XHRBackend(_browserXHR,_baseResponseOptions,_xsrfStrategy){this._browserXHR=_browserXHR,this._baseResponseOptions=_baseResponseOptions,this._xsrfStrategy=_xsrfStrategy}return XHRBackend.prototype.createConnection=function(request){return this._xsrfStrategy.configureRequest(request),new XHRConnection(request,this._browserXHR,this._baseResponseOptions)},XHRBackend.decorators=[{type:_angular_core.Injectable}],XHRBackend.ctorParameters=function(){return[{type:BrowserXhr},{type:ResponseOptions},{type:XSRFStrategy}]},XHRBackend}(),__extends$3=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},RequestOptions=function(){function RequestOptions(_a){var _b=void 0===_a?{}:_a,method=_b.method,headers=_b.headers,body=_b.body,url=_b.url,search=_b.search,withCredentials=_b.withCredentials,responseType=_b.responseType;this.method=null!=method?normalizeMethodName(method):null,this.headers=null!=headers?headers:null,this.body=null!=body?body:null,this.url=null!=url?url:null,this.search=null!=search?"string"==typeof search?new URLSearchParams(search):search:null,this.withCredentials=null!=withCredentials?withCredentials:null,this.responseType=null!=responseType?responseType:null}return RequestOptions.prototype.merge=function(options){return new RequestOptions({method:options&&null!=options.method?options.method:this.method,headers:options&&null!=options.headers?options.headers:this.headers,body:options&&null!=options.body?options.body:this.body,url:options&&null!=options.url?options.url:this.url,search:options&&null!=options.search?"string"==typeof options.search?new URLSearchParams(options.search):options.search.clone():this.search,withCredentials:options&&null!=options.withCredentials?options.withCredentials:this.withCredentials,responseType:options&&null!=options.responseType?options.responseType:this.responseType})},RequestOptions}(),BaseRequestOptions=function(_super){function BaseRequestOptions(){_super.call(this,{method:RequestMethod.Get,headers:new Headers})}return __extends$3(BaseRequestOptions,_super),BaseRequestOptions.decorators=[{type:_angular_core.Injectable}],BaseRequestOptions.ctorParameters=function(){return[]},BaseRequestOptions}(RequestOptions),__extends$5=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Request=function(_super){function Request(requestOptions){_super.call(this);var url=requestOptions.url;if(this.url=requestOptions.url,requestOptions.search){var search=requestOptions.search.toString();if(search.length>0){var prefix="?";this.url.indexOf("?")!=-1&&(prefix="&"==this.url[this.url.length-1]?"":"&"),this.url=url+prefix+search}}this._body=requestOptions.body,this.method=normalizeMethodName(requestOptions.method),this.headers=new Headers(requestOptions.headers),this.contentType=this.detectContentType(),this.withCredentials=requestOptions.withCredentials,this.responseType=requestOptions.responseType}return __extends$5(Request,_super),Request.prototype.detectContentType=function(){switch(this.headers.get("content-type")){case"application/json":return ContentType.JSON;case"application/x-www-form-urlencoded":return ContentType.FORM;case"multipart/form-data":return ContentType.FORM_DATA;case"text/plain":case"text/html":return ContentType.TEXT;case"application/octet-stream":return ContentType.BLOB;default:return this.detectContentTypeFromBody()}},Request.prototype.detectContentTypeFromBody=function(){return null==this._body?ContentType.NONE:this._body instanceof URLSearchParams?ContentType.FORM:this._body instanceof FormData?ContentType.FORM_DATA:this._body instanceof Blob$1?ContentType.BLOB:this._body instanceof ArrayBuffer$1?ContentType.ARRAY_BUFFER:this._body&&"object"==typeof this._body?ContentType.JSON:ContentType.TEXT},Request.prototype.getBody=function(){switch(this.contentType){case ContentType.JSON:return this.text();case ContentType.FORM:return this.text();case ContentType.FORM_DATA:return this._body;case ContentType.TEXT:return this.text();case ContentType.BLOB:return this.blob();case ContentType.ARRAY_BUFFER:return this.arrayBuffer();default:return null}},Request}(Body),noop=function(){},w="object"==typeof window?window:noop,FormData=w.FormData||noop,Blob$1=w.Blob||noop,ArrayBuffer$1=w.ArrayBuffer||noop,__extends$4=this&&this.__extends||function(d,b){function __(){this.constructor=d}for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p]);d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)},Http=function(){function Http(_backend,_defaultOptions){this._backend=_backend,this._defaultOptions=_defaultOptions}return Http.prototype.request=function(url,options){var responseObservable;if("string"==typeof url)responseObservable=httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Get,url)));else{if(!(url instanceof Request))throw new Error("First argument must be a url string or Request instance.");responseObservable=httpRequest(this._backend,url)}return responseObservable},Http.prototype.get=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Get,url)))},Http.prototype.post=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,RequestMethod.Post,url)))},Http.prototype.put=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,RequestMethod.Put,url)))},Http.prototype.delete=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Delete,url)))},Http.prototype.patch=function(url,body,options){return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,RequestMethod.Patch,url)))},Http.prototype.head=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Head,url)))},Http.prototype.options=function(url,options){return this.request(new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Options,url)))},Http.decorators=[{type:_angular_core.Injectable}],Http.ctorParameters=function(){return[{type:ConnectionBackend},{type:RequestOptions}]},Http}(),Jsonp=function(_super){function Jsonp(backend,defaultOptions){_super.call(this,backend,defaultOptions)}return __extends$4(Jsonp,_super),Jsonp.prototype.request=function(url,options){var responseObservable;if("string"==typeof url&&(url=new Request(mergeOptions(this._defaultOptions,options,RequestMethod.Get,url))),!(url instanceof Request))throw new Error("First argument must be a url string or Request instance.");if(url.method!==RequestMethod.Get)throw new Error("JSONP requests must use GET request method.");return responseObservable=httpRequest(this._backend,url)},Jsonp.decorators=[{type:_angular_core.Injectable}],Jsonp.ctorParameters=function(){return[{type:ConnectionBackend},{type:RequestOptions}]},Jsonp}(Http),HttpModule=function(){function HttpModule(){}return HttpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:[{provide:Http,useFactory:httpFactory,deps:[XHRBackend,RequestOptions]},BrowserXhr,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},XHRBackend,{provide:XSRFStrategy,useFactory:_createDefaultCookieXSRFStrategy}]}]}],HttpModule.ctorParameters=function(){return[]},HttpModule}(),JsonpModule=function(){function JsonpModule(){}return JsonpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:[{provide:Jsonp,useFactory:jsonpFactory,deps:[JSONPBackend,RequestOptions]},BrowserJsonp,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},{provide:JSONPBackend,useClass:JSONPBackend_}]}]}],JsonpModule.ctorParameters=function(){return[]},JsonpModule}();exports.BrowserXhr=BrowserXhr,exports.JSONPBackend=JSONPBackend,exports.JSONPConnection=JSONPConnection,exports.CookieXSRFStrategy=CookieXSRFStrategy,exports.XHRBackend=XHRBackend,exports.XHRConnection=XHRConnection,exports.BaseRequestOptions=BaseRequestOptions,exports.RequestOptions=RequestOptions,exports.BaseResponseOptions=BaseResponseOptions,exports.ResponseOptions=ResponseOptions,exports.ReadyState=ReadyState,exports.RequestMethod=RequestMethod,exports.ResponseContentType=ResponseContentType,exports.ResponseType=ResponseType,exports.Headers=Headers,exports.Http=Http,exports.Jsonp=Jsonp,exports.HttpModule=HttpModule,exports.JsonpModule=JsonpModule,exports.Connection=Connection,exports.ConnectionBackend=ConnectionBackend,exports.XSRFStrategy=XSRFStrategy,exports.Request=Request,exports.Response=Response,exports.QueryEncoder=QueryEncoder,exports.URLSearchParams=URLSearchParams}); |
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
export * from './src/index'; | ||
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 } from './src/index'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./src/index"}]} | ||
{"__symbolic":"module","version":2,"metadata":{},"exports":[{"from":"./src/index"}]} |
{ | ||
"name": "@angular/http", | ||
"version": "2.3.0-beta.0", | ||
"version": "2.3.0-beta.1", | ||
"description": "Angular - the http service", | ||
@@ -12,4 +12,4 @@ "main": "bundles/http.umd.js", | ||
"rxjs": "5.0.0-beta.12", | ||
"@angular/core": "2.3.0-beta.0", | ||
"@angular/platform-browser": "2.3.0-beta.0" | ||
"@angular/core": "2.3.0-beta.1", | ||
"@angular/platform-browser": "2.3.0-beta.1" | ||
}, | ||
@@ -16,0 +16,0 @@ "repository": { |
@@ -9,7 +9,10 @@ /** | ||
import { Injectable } from '@angular/core'; | ||
var _nextRequestId = 0; | ||
export var JSONP_HOME = '__ng_jsonp__'; | ||
var _jsonpConnections = null; | ||
var /** @type {?} */ _nextRequestId = 0; | ||
export var /** @type {?} */ JSONP_HOME = '__ng_jsonp__'; | ||
var /** @type {?} */ _jsonpConnections = null; | ||
/** | ||
* @return {?} | ||
*/ | ||
function _getJsonpConnections() { | ||
var w = typeof window == 'object' ? window : {}; | ||
var /** @type {?} */ w = typeof window == 'object' ? window : {}; | ||
if (_jsonpConnections === null) { | ||
@@ -24,24 +27,49 @@ _jsonpConnections = w[JSONP_HOME] = {}; | ||
} | ||
// Construct a <script> element with the specified URL | ||
/** | ||
* @param {?} url | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.build = function (url) { | ||
var node = document.createElement('script'); | ||
var /** @type {?} */ node = document.createElement('script'); | ||
node.src = url; | ||
return node; | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.nextRequestID = function () { return "__req" + _nextRequestId++; }; | ||
/** | ||
* @param {?} id | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.requestCallback = function (id) { return JSONP_HOME + "." + id + ".finished"; }; | ||
/** | ||
* @param {?} id | ||
* @param {?} connection | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.exposeConnection = function (id, connection) { | ||
var connections = _getJsonpConnections(); | ||
var /** @type {?} */ connections = _getJsonpConnections(); | ||
connections[id] = connection; | ||
}; | ||
/** | ||
* @param {?} id | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.removeConnection = function (id) { | ||
var connections = _getJsonpConnections(); | ||
var /** @type {?} */ connections = _getJsonpConnections(); | ||
connections[id] = null; | ||
}; | ||
// Attach the <script> element to the DOM | ||
BrowserJsonp.prototype.send = function (node) { document.body.appendChild((node)); }; | ||
// Remove <script> element from the DOM | ||
/** | ||
* @param {?} node | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.send = function (node) { document.body.appendChild(/** @type {?} */ ((node))); }; | ||
/** | ||
* @param {?} node | ||
* @return {?} | ||
*/ | ||
BrowserJsonp.prototype.cleanup = function (node) { | ||
if (node.parentNode) { | ||
node.parentNode.removeChild((node)); | ||
node.parentNode.removeChild(/** @type {?} */ ((node))); | ||
} | ||
@@ -53,5 +81,14 @@ }; | ||
/** @nocollapse */ | ||
BrowserJsonp.ctorParameters = []; | ||
BrowserJsonp.ctorParameters = function () { return []; }; | ||
return BrowserJsonp; | ||
}()); | ||
function BrowserJsonp_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
BrowserJsonp.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
BrowserJsonp.ctorParameters; | ||
} | ||
//# sourceMappingURL=browser_jsonp.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"JSONP_HOME":"__ng_jsonp__","BrowserJsonp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"build":[{"__symbolic":"method"}],"nextRequestID":[{"__symbolic":"method"}],"requestCallback":[{"__symbolic":"method"}],"exposeConnection":[{"__symbolic":"method"}],"removeConnection":[{"__symbolic":"method"}],"send":[{"__symbolic":"method"}],"cleanup":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"JSONP_HOME":"__ng_jsonp__","BrowserJsonp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"build":[{"__symbolic":"method"}],"nextRequestID":[{"__symbolic":"method"}],"requestCallback":[{"__symbolic":"method"}],"exposeConnection":[{"__symbolic":"method"}],"removeConnection":[{"__symbolic":"method"}],"send":[{"__symbolic":"method"}],"cleanup":[{"__symbolic":"method"}]}}}} |
@@ -10,7 +10,6 @@ /** | ||
/** | ||
* A backend for http that uses the `XMLHttpRequest` browser API. | ||
* | ||
* Take care not to evaluate this in non-browser contexts. | ||
* | ||
* @experimental | ||
* A backend for http that uses the `XMLHttpRequest` browser API. | ||
* * | ||
* Take care not to evaluate this in non-browser contexts. | ||
* * | ||
*/ | ||
@@ -20,3 +19,6 @@ export var BrowserXhr = (function () { | ||
} | ||
BrowserXhr.prototype.build = function () { return (new XMLHttpRequest()); }; | ||
/** | ||
* @return {?} | ||
*/ | ||
BrowserXhr.prototype.build = function () { return ((new XMLHttpRequest())); }; | ||
BrowserXhr.decorators = [ | ||
@@ -26,5 +28,14 @@ { type: Injectable }, | ||
/** @nocollapse */ | ||
BrowserXhr.ctorParameters = []; | ||
BrowserXhr.ctorParameters = function () { return []; }; | ||
return BrowserXhr; | ||
}()); | ||
function BrowserXhr_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
BrowserXhr.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
BrowserXhr.ctorParameters; | ||
} | ||
//# sourceMappingURL=browser_xhr.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"BrowserXhr":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"build":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"BrowserXhr":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"build":[{"__symbolic":"method"}]}}}} |
@@ -20,8 +20,8 @@ /** | ||
import { BrowserJsonp } from './browser_jsonp'; | ||
var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.'; | ||
var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.'; | ||
var /** @type {?} */ JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.'; | ||
var /** @type {?} */ JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.'; | ||
/** | ||
* Abstract base class for an in-flight JSONP request. | ||
* | ||
* @experimental | ||
* Abstract base class for an in-flight JSONP request. | ||
* * | ||
* @abstract | ||
*/ | ||
@@ -31,6 +31,36 @@ export var JSONPConnection = (function () { | ||
} | ||
/** | ||
* Callback called when the JSONP request completes, to notify the application | ||
* of the new data. | ||
* @abstract | ||
* @param {?=} data | ||
* @return {?} | ||
*/ | ||
JSONPConnection.prototype.finished = function (data) { }; | ||
return JSONPConnection; | ||
}()); | ||
function JSONPConnection_tsickle_Closure_declarations() { | ||
/** | ||
* The {@link ReadyState} of this request. | ||
* @type {?} | ||
*/ | ||
JSONPConnection.prototype.readyState; | ||
/** | ||
* The outgoing HTTP request. | ||
* @type {?} | ||
*/ | ||
JSONPConnection.prototype.request; | ||
/** | ||
* An observable that completes with the response, when the request is finished. | ||
* @type {?} | ||
*/ | ||
JSONPConnection.prototype.response; | ||
} | ||
export var JSONPConnection_ = (function (_super) { | ||
__extends(JSONPConnection_, _super); | ||
/** | ||
* @param {?} req | ||
* @param {?} _dom | ||
* @param {?=} baseResponseOptions | ||
*/ | ||
function JSONPConnection_(req, _dom, baseResponseOptions) { | ||
@@ -103,2 +133,6 @@ var _this = this; | ||
} | ||
/** | ||
* @param {?=} data | ||
* @return {?} | ||
*/ | ||
JSONPConnection_.prototype.finished = function (data) { | ||
@@ -114,6 +148,20 @@ // Don't leak connections | ||
}(JSONPConnection)); | ||
function JSONPConnection__tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
JSONPConnection_.prototype._id; | ||
/** @type {?} */ | ||
JSONPConnection_.prototype._script; | ||
/** @type {?} */ | ||
JSONPConnection_.prototype._responseData; | ||
/** @type {?} */ | ||
JSONPConnection_.prototype._finished; | ||
/** @type {?} */ | ||
JSONPConnection_.prototype._dom; | ||
/** @type {?} */ | ||
JSONPConnection_.prototype.baseResponseOptions; | ||
} | ||
/** | ||
* A {@link ConnectionBackend} that uses the JSONP strategy of making requests. | ||
* | ||
* @experimental | ||
* A {@link ConnectionBackend} that uses the JSONP strategy of making requests. | ||
* * | ||
* @abstract | ||
*/ | ||
@@ -129,2 +177,6 @@ export var JSONPBackend = (function (_super) { | ||
__extends(JSONPBackend_, _super); | ||
/** | ||
* @param {?} _browserJSONP | ||
* @param {?} _baseResponseOptions | ||
*/ | ||
function JSONPBackend_(_browserJSONP, _baseResponseOptions) { | ||
@@ -135,2 +187,6 @@ _super.call(this); | ||
} | ||
/** | ||
* @param {?} request | ||
* @return {?} | ||
*/ | ||
JSONPBackend_.prototype.createConnection = function (request) { | ||
@@ -143,8 +199,21 @@ return new JSONPConnection_(request, this._browserJSONP, this._baseResponseOptions); | ||
/** @nocollapse */ | ||
JSONPBackend_.ctorParameters = [ | ||
JSONPBackend_.ctorParameters = function () { return [ | ||
{ type: BrowserJsonp, }, | ||
{ type: ResponseOptions, }, | ||
]; | ||
]; }; | ||
return JSONPBackend_; | ||
}(JSONPBackend)); | ||
function JSONPBackend__tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
JSONPBackend_.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
JSONPBackend_.ctorParameters; | ||
/** @type {?} */ | ||
JSONPBackend_.prototype._browserJSONP; | ||
/** @type {?} */ | ||
JSONPBackend_.prototype._baseResponseOptions; | ||
} | ||
//# sourceMappingURL=jsonp_backend.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"JSONPBackend_":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./browser_jsonp","name":"BrowserJsonp"},{"__symbolic":"reference","module":"../base_response_options","name":"ResponseOptions"}]}],"createConnection":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"JSONPConnection":{"__symbolic":"class"},"JSONPConnection_":{"__symbolic":"class"},"JSONPBackend":{"__symbolic":"class"},"JSONPBackend_":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./browser_jsonp","name":"BrowserJsonp"},{"__symbolic":"reference","module":"../base_response_options","name":"ResponseOptions"}]}],"createConnection":[{"__symbolic":"method"}]}}}} |
@@ -18,14 +18,18 @@ /** | ||
import { BrowserXhr } from './browser_xhr'; | ||
var XSSI_PREFIX = /^\)\]\}',?\n/; | ||
var /** @type {?} */ XSSI_PREFIX = /^\)\]\}',?\n/; | ||
/** | ||
* Creates connections using `XMLHttpRequest`. Given a fully-qualified | ||
* request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the | ||
* request. | ||
* | ||
* This class would typically not be created or interacted with directly inside applications, though | ||
* the {@link MockConnection} may be interacted with in tests. | ||
* | ||
* @experimental | ||
* Creates connections using `XMLHttpRequest`. Given a fully-qualified | ||
* request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the | ||
* request. | ||
* * | ||
* This class would typically not be created or interacted with directly inside applications, though | ||
* the {@link MockConnection} may be interacted with in tests. | ||
* * | ||
*/ | ||
export var XHRConnection = (function () { | ||
/** | ||
* @param {?} req | ||
* @param {?} browserXHR | ||
* @param {?=} baseResponseOptions | ||
*/ | ||
function XHRConnection(req, browserXHR, baseResponseOptions) { | ||
@@ -126,2 +130,7 @@ var _this = this; | ||
} | ||
/** | ||
* @param {?} req | ||
* @param {?} _xhr | ||
* @return {?} | ||
*/ | ||
XHRConnection.prototype.setDetectedContentType = function (req /** TODO Request */, _xhr /** XMLHttpRequest */) { | ||
@@ -146,3 +155,3 @@ // Skip if a custom Content-Type header is provided | ||
case ContentType.BLOB: | ||
var blob = req.blob(); | ||
var /** @type {?} */ blob = req.blob(); | ||
if (blob.type) { | ||
@@ -156,14 +165,29 @@ _xhr.setRequestHeader('content-type', blob.type); | ||
}()); | ||
function XHRConnection_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
XHRConnection.prototype.request; | ||
/** | ||
* Response {@link EventEmitter} which emits a single {@link Response} value on load event of | ||
* `XMLHttpRequest`. | ||
* @type {?} | ||
*/ | ||
XHRConnection.prototype.response; | ||
/** @type {?} */ | ||
XHRConnection.prototype.readyState; | ||
} | ||
/** | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* | ||
* Applications can configure custom cookie and header names by binding an instance of this class | ||
* with different `cookieName` and `headerName` values. See the main HTTP documentation for more | ||
* details. | ||
* | ||
* @experimental | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* * | ||
* Applications can configure custom cookie and header names by binding an instance of this class | ||
* with different `cookieName` and `headerName` values. See the main HTTP documentation for more | ||
* details. | ||
* * | ||
*/ | ||
export var CookieXSRFStrategy = (function () { | ||
/** | ||
* @param {?=} _cookieName | ||
* @param {?=} _headerName | ||
*/ | ||
function CookieXSRFStrategy(_cookieName, _headerName) { | ||
@@ -175,4 +199,8 @@ if (_cookieName === void 0) { _cookieName = 'XSRF-TOKEN'; } | ||
} | ||
/** | ||
* @param {?} req | ||
* @return {?} | ||
*/ | ||
CookieXSRFStrategy.prototype.configureRequest = function (req) { | ||
var xsrfToken = __platform_browser_private__.getDOM().getCookie(this._cookieName); | ||
var /** @type {?} */ xsrfToken = __platform_browser_private__.getDOM().getCookie(this._cookieName); | ||
if (xsrfToken) { | ||
@@ -184,29 +212,38 @@ req.headers.set(this._headerName, xsrfToken); | ||
}()); | ||
function CookieXSRFStrategy_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
CookieXSRFStrategy.prototype._cookieName; | ||
/** @type {?} */ | ||
CookieXSRFStrategy.prototype._headerName; | ||
} | ||
/** | ||
* Creates {@link XHRConnection} instances. | ||
* | ||
* This class would typically not be used by end users, but could be | ||
* overridden if a different backend implementation should be used, | ||
* such as in a node backend. | ||
* | ||
* ### Example | ||
* | ||
* ``` | ||
* import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http'; | ||
* @Component({ | ||
* viewProviders: [ | ||
* HTTP_PROVIDERS, | ||
* {provide: Http, useFactory: (backend, options) => { | ||
* return new Http(backend, options); | ||
* }, deps: [MyNodeBackend, BaseRequestOptions]}] | ||
* }) | ||
* class MyComponent { | ||
* constructor(http:Http) { | ||
* http.request('people.json').subscribe(res => this.people = res.json()); | ||
* } | ||
* } | ||
* ``` | ||
* @experimental | ||
* Creates {@link XHRConnection} instances. | ||
* * | ||
* This class would typically not be used by end users, but could be | ||
* overridden if a different backend implementation should be used, | ||
* such as in a node backend. | ||
* * | ||
* ### Example | ||
* * | ||
* ``` | ||
* import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http'; | ||
* viewProviders: [ | ||
* HTTP_PROVIDERS, | ||
* {provide: Http, useFactory: (backend, options) => { | ||
* return new Http(backend, options); | ||
* }, deps: [MyNodeBackend, BaseRequestOptions]}] | ||
* }) | ||
* class MyComponent { | ||
* constructor(http:Http) { | ||
* http.request('people.json').subscribe(res => this.people = res.json()); | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
export var XHRBackend = (function () { | ||
/** | ||
* @param {?} _browserXHR | ||
* @param {?} _baseResponseOptions | ||
* @param {?} _xsrfStrategy | ||
*/ | ||
function XHRBackend(_browserXHR, _baseResponseOptions, _xsrfStrategy) { | ||
@@ -217,2 +254,6 @@ this._browserXHR = _browserXHR; | ||
} | ||
/** | ||
* @param {?} request | ||
* @return {?} | ||
*/ | ||
XHRBackend.prototype.createConnection = function (request) { | ||
@@ -226,9 +267,24 @@ this._xsrfStrategy.configureRequest(request); | ||
/** @nocollapse */ | ||
XHRBackend.ctorParameters = [ | ||
XHRBackend.ctorParameters = function () { return [ | ||
{ type: BrowserXhr, }, | ||
{ type: ResponseOptions, }, | ||
{ type: XSRFStrategy, }, | ||
]; | ||
]; }; | ||
return XHRBackend; | ||
}()); | ||
function XHRBackend_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
XHRBackend.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
XHRBackend.ctorParameters; | ||
/** @type {?} */ | ||
XHRBackend.prototype._browserXHR; | ||
/** @type {?} */ | ||
XHRBackend.prototype._baseResponseOptions; | ||
/** @type {?} */ | ||
XHRBackend.prototype._xsrfStrategy; | ||
} | ||
//# sourceMappingURL=xhr_backend.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"XHRBackend":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./browser_xhr","name":"BrowserXhr"},{"__symbolic":"reference","module":"../base_response_options","name":"ResponseOptions"},{"__symbolic":"reference","module":"../interfaces","name":"XSRFStrategy"}]}],"createConnection":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"XHRConnection":{"__symbolic":"class"},"CookieXSRFStrategy":{"__symbolic":"class"},"XHRBackend":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./browser_xhr","name":"BrowserXhr"},{"__symbolic":"reference","module":"../base_response_options","name":"ResponseOptions"},{"__symbolic":"reference","module":"../interfaces","name":"XSRFStrategy"}]}],"createConnection":[{"__symbolic":"method"}]}}}} |
@@ -19,28 +19,30 @@ /** | ||
/** | ||
* Creates a request options object to be optionally provided when instantiating a | ||
* {@link Request}. | ||
* | ||
* This class is based on the `RequestInit` description in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#requestinit). | ||
* | ||
* All values are null by default. Typical defaults can be found in the {@link BaseRequestOptions} | ||
* class, which sub-classes `RequestOptions`. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/7Wvi3lfLq41aQPKlxB4O?p=preview)) | ||
* | ||
* ```typescript | ||
* import {RequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* | ||
* var options = new RequestOptions({ | ||
* method: RequestMethod.Post, | ||
* url: 'https://google.com' | ||
* }); | ||
* var req = new Request(options); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // https://google.com | ||
* ``` | ||
* | ||
* @experimental | ||
* Creates a request options object to be optionally provided when instantiating a | ||
* {@link Request}. | ||
* * | ||
* This class is based on the `RequestInit` description in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#requestinit). | ||
* * | ||
* All values are null by default. Typical defaults can be found in the {@link BaseRequestOptions} | ||
* class, which sub-classes `RequestOptions`. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/7Wvi3lfLq41aQPKlxB4O?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {RequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* * | ||
* var options = new RequestOptions({ | ||
* method: RequestMethod.Post, | ||
* url: 'https://google.com' | ||
* }); | ||
* var req = new Request(options); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // https://google.com | ||
* ``` | ||
* * | ||
*/ | ||
export var RequestOptions = (function () { | ||
/** | ||
* @param {?=} __0 | ||
*/ | ||
function RequestOptions(_a) { | ||
@@ -58,25 +60,27 @@ var _b = _a === void 0 ? {} : _a, method = _b.method, headers = _b.headers, body = _b.body, url = _b.url, search = _b.search, withCredentials = _b.withCredentials, responseType = _b.responseType; | ||
/** | ||
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override | ||
* existing values. This method will not change the values of the instance on which it is being | ||
* called. | ||
* | ||
* Note that `headers` and `search` will override existing values completely if present in | ||
* the `options` object. If these values should be merged, it should be done prior to calling | ||
* `merge` on the `RequestOptions` instance. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/6w8XA8YTkDRcPYpdB9dk?p=preview)) | ||
* | ||
* ```typescript | ||
* import {RequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* | ||
* var options = new RequestOptions({ | ||
* method: RequestMethod.Post | ||
* }); | ||
* var req = new Request(options.merge({ | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // null | ||
* console.log('req.url:', req.url); // https://google.com | ||
* ``` | ||
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override | ||
* existing values. This method will not change the values of the instance on which it is being | ||
* called. | ||
* * | ||
* Note that `headers` and `search` will override existing values completely if present in | ||
* the `options` object. If these values should be merged, it should be done prior to calling | ||
* `merge` on the `RequestOptions` instance. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/6w8XA8YTkDRcPYpdB9dk?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {RequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* * | ||
* var options = new RequestOptions({ | ||
* method: RequestMethod.Post | ||
* }); | ||
* var req = new Request(options.merge({ | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // null | ||
* console.log('req.url:', req.url); // https://google.com | ||
* ``` | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -101,47 +105,81 @@ RequestOptions.prototype.merge = function (options) { | ||
}()); | ||
function RequestOptions_tsickle_Closure_declarations() { | ||
/** | ||
* Http method with which to execute a {@link Request}. | ||
* Acceptable methods are defined in the {@link RequestMethod} enum. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.method; | ||
/** | ||
* {@link Headers} to be attached to a {@link Request}. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.headers; | ||
/** | ||
* Body to be used when creating a {@link Request}. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.body; | ||
/** | ||
* Url with which to perform a {@link Request}. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.url; | ||
/** | ||
* Search parameters to be included in a {@link Request}. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.search; | ||
/** | ||
* Enable use credentials for a {@link Request}. | ||
* @type {?} | ||
*/ | ||
RequestOptions.prototype.withCredentials; | ||
/** @type {?} */ | ||
RequestOptions.prototype.responseType; | ||
} | ||
/** | ||
* Subclass of {@link RequestOptions}, with default values. | ||
* | ||
* Default values: | ||
* * method: {@link RequestMethod RequestMethod.Get} | ||
* * headers: empty {@link Headers} object | ||
* | ||
* This class could be extended and bound to the {@link RequestOptions} class | ||
* when configuring an {@link Injector}, in order to override the default options | ||
* used by {@link Http} to create and send {@link Request Requests}. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/LEKVSx?p=preview)) | ||
* | ||
* ```typescript | ||
* import {provide} from '@angular/core'; | ||
* import {bootstrap} from '@angular/platform-browser/browser'; | ||
* import {HTTP_PROVIDERS, Http, BaseRequestOptions, RequestOptions} from '@angular/http'; | ||
* import {App} from './myapp'; | ||
* | ||
* class MyOptions extends BaseRequestOptions { | ||
* search: string = 'coreTeam=true'; | ||
* } | ||
* | ||
* bootstrap(App, [HTTP_PROVIDERS, {provide: RequestOptions, useClass: MyOptions}]); | ||
* ``` | ||
* | ||
* The options could also be extended when manually creating a {@link Request} | ||
* object. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/oyBoEvNtDhOSfi9YxaVb?p=preview)) | ||
* | ||
* ``` | ||
* import {BaseRequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* | ||
* var options = new BaseRequestOptions(); | ||
* var req = new Request(options.merge({ | ||
* method: RequestMethod.Post, | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // null | ||
* console.log('req.url:', req.url); // https://google.com | ||
* ``` | ||
* | ||
* @experimental | ||
* Subclass of {@link RequestOptions}, with default values. | ||
* * | ||
* Default values: | ||
* * method: {@link RequestMethod RequestMethod.Get} | ||
* * headers: empty {@link Headers} object | ||
* * | ||
* This class could be extended and bound to the {@link RequestOptions} class | ||
* when configuring an {@link Injector}, in order to override the default options | ||
* used by {@link Http} to create and send {@link Request Requests}. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/LEKVSx?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {provide} from '@angular/core'; | ||
* import {bootstrap} from '@angular/platform-browser/browser'; | ||
* import {HTTP_PROVIDERS, Http, BaseRequestOptions, RequestOptions} from '@angular/http'; | ||
* import {App} from './myapp'; | ||
* * | ||
* class MyOptions extends BaseRequestOptions { | ||
* search: string = 'coreTeam=true'; | ||
* } | ||
* * | ||
* bootstrap(App, [HTTP_PROVIDERS, {provide: RequestOptions, useClass: MyOptions}]); | ||
* ``` | ||
* * | ||
* The options could also be extended when manually creating a {@link Request} | ||
* object. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/oyBoEvNtDhOSfi9YxaVb?p=preview)) | ||
* * | ||
* ``` | ||
* import {BaseRequestOptions, Request, RequestMethod} from '@angular/http'; | ||
* * | ||
* var options = new BaseRequestOptions(); | ||
* var req = new Request(options.merge({ | ||
* method: RequestMethod.Post, | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('req.method:', RequestMethod[req.method]); // Post | ||
* console.log('options.url:', options.url); // null | ||
* console.log('req.url:', req.url); // https://google.com | ||
* ``` | ||
* * | ||
*/ | ||
@@ -157,5 +195,14 @@ export var BaseRequestOptions = (function (_super) { | ||
/** @nocollapse */ | ||
BaseRequestOptions.ctorParameters = []; | ||
BaseRequestOptions.ctorParameters = function () { return []; }; | ||
return BaseRequestOptions; | ||
}(RequestOptions)); | ||
function BaseRequestOptions_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
BaseRequestOptions.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
BaseRequestOptions.ctorParameters; | ||
} | ||
//# sourceMappingURL=base_request_options.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"BaseRequestOptions":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"RequestOptions":{"__symbolic":"class"},"BaseRequestOptions":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}]}}}} |
@@ -17,30 +17,32 @@ /** | ||
/** | ||
* Creates a response options object to be optionally provided when instantiating a | ||
* {@link Response}. | ||
* | ||
* This class is based on the `ResponseInit` description in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#responseinit). | ||
* | ||
* All values are null by default. Typical defaults can be found in the | ||
* {@link BaseResponseOptions} class, which sub-classes `ResponseOptions`. | ||
* | ||
* This class may be used in tests to build {@link Response Responses} for | ||
* mock responses (see {@link MockBackend}). | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview)) | ||
* | ||
* ```typescript | ||
* import {ResponseOptions, Response} from '@angular/http'; | ||
* | ||
* var options = new ResponseOptions({ | ||
* body: '{"name":"Jeff"}' | ||
* }); | ||
* var res = new Response(options); | ||
* | ||
* console.log('res.json():', res.json()); // Object {name: "Jeff"} | ||
* ``` | ||
* | ||
* @experimental | ||
* Creates a response options object to be optionally provided when instantiating a | ||
* {@link Response}. | ||
* * | ||
* This class is based on the `ResponseInit` description in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#responseinit). | ||
* * | ||
* All values are null by default. Typical defaults can be found in the | ||
* {@link BaseResponseOptions} class, which sub-classes `ResponseOptions`. | ||
* * | ||
* This class may be used in tests to build {@link Response Responses} for | ||
* mock responses (see {@link MockBackend}). | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {ResponseOptions, Response} from '@angular/http'; | ||
* * | ||
* var options = new ResponseOptions({ | ||
* body: '{"name":"Jeff"}' | ||
* }); | ||
* var res = new Response(options); | ||
* * | ||
* console.log('res.json():', res.json()); // Object {name: "Jeff"} | ||
* ``` | ||
* * | ||
*/ | ||
export var ResponseOptions = (function () { | ||
/** | ||
* @param {?=} __0 | ||
*/ | ||
function ResponseOptions(_a) { | ||
@@ -56,25 +58,27 @@ var _b = _a === void 0 ? {} : _a, body = _b.body, status = _b.status, headers = _b.headers, statusText = _b.statusText, type = _b.type, url = _b.url; | ||
/** | ||
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to | ||
* override | ||
* existing values. This method will not change the values of the instance on which it is being | ||
* called. | ||
* | ||
* This may be useful when sharing a base `ResponseOptions` object inside tests, | ||
* where certain properties may change from test to test. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview)) | ||
* | ||
* ```typescript | ||
* import {ResponseOptions, Response} from '@angular/http'; | ||
* | ||
* var options = new ResponseOptions({ | ||
* body: {name: 'Jeff'} | ||
* }); | ||
* var res = new Response(options.merge({ | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('options.url:', options.url); // null | ||
* console.log('res.json():', res.json()); // Object {name: "Jeff"} | ||
* console.log('res.url:', res.url); // https://google.com | ||
* ``` | ||
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to | ||
* override | ||
* existing values. This method will not change the values of the instance on which it is being | ||
* called. | ||
* * | ||
* This may be useful when sharing a base `ResponseOptions` object inside tests, | ||
* where certain properties may change from test to test. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {ResponseOptions, Response} from '@angular/http'; | ||
* * | ||
* var options = new ResponseOptions({ | ||
* body: {name: 'Jeff'} | ||
* }); | ||
* var res = new Response(options.merge({ | ||
* url: 'https://google.com' | ||
* })); | ||
* console.log('options.url:', options.url); // null | ||
* console.log('res.json():', res.json()); // Object {name: "Jeff"} | ||
* console.log('res.url:', res.url); // https://google.com | ||
* ``` | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -93,47 +97,70 @@ ResponseOptions.prototype.merge = function (options) { | ||
}()); | ||
function ResponseOptions_tsickle_Closure_declarations() { | ||
/** | ||
* String, Object, ArrayBuffer or Blob representing the body of the {@link Response}. | ||
* @type {?} | ||
*/ | ||
ResponseOptions.prototype.body; | ||
/** | ||
* Http {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html status code} | ||
* associated with the response. | ||
* @type {?} | ||
*/ | ||
ResponseOptions.prototype.status; | ||
/** | ||
* Response {@link Headers headers} | ||
* @type {?} | ||
*/ | ||
ResponseOptions.prototype.headers; | ||
/** @type {?} */ | ||
ResponseOptions.prototype.statusText; | ||
/** @type {?} */ | ||
ResponseOptions.prototype.type; | ||
/** @type {?} */ | ||
ResponseOptions.prototype.url; | ||
} | ||
/** | ||
* Subclass of {@link ResponseOptions}, with default values. | ||
* | ||
* Default values: | ||
* * status: 200 | ||
* * headers: empty {@link Headers} object | ||
* | ||
* This class could be extended and bound to the {@link ResponseOptions} class | ||
* when configuring an {@link Injector}, in order to override the default options | ||
* used by {@link Http} to create {@link Response Responses}. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview)) | ||
* | ||
* ```typescript | ||
* import {provide} from '@angular/core'; | ||
* import {bootstrap} from '@angular/platform-browser/browser'; | ||
* import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from | ||
* '@angular/http'; | ||
* import {App} from './myapp'; | ||
* | ||
* class MyOptions extends BaseResponseOptions { | ||
* headers:Headers = new Headers({network: 'github'}); | ||
* } | ||
* | ||
* bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]); | ||
* ``` | ||
* | ||
* The options could also be extended when manually creating a {@link Response} | ||
* object. | ||
* | ||
* ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview)) | ||
* | ||
* ``` | ||
* import {BaseResponseOptions, Response} from '@angular/http'; | ||
* | ||
* var options = new BaseResponseOptions(); | ||
* var res = new Response(options.merge({ | ||
* body: 'Angular', | ||
* headers: new Headers({framework: 'angular'}) | ||
* })); | ||
* console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular | ||
* console.log('res.text():', res.text()); // Angular; | ||
* ``` | ||
* | ||
* @experimental | ||
* Subclass of {@link ResponseOptions}, with default values. | ||
* * | ||
* Default values: | ||
* * status: 200 | ||
* * headers: empty {@link Headers} object | ||
* * | ||
* This class could be extended and bound to the {@link ResponseOptions} class | ||
* when configuring an {@link Injector}, in order to override the default options | ||
* used by {@link Http} to create {@link Response Responses}. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview)) | ||
* * | ||
* ```typescript | ||
* import {provide} from '@angular/core'; | ||
* import {bootstrap} from '@angular/platform-browser/browser'; | ||
* import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from | ||
* '@angular/http'; | ||
* import {App} from './myapp'; | ||
* * | ||
* class MyOptions extends BaseResponseOptions { | ||
* headers:Headers = new Headers({network: 'github'}); | ||
* } | ||
* * | ||
* bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]); | ||
* ``` | ||
* * | ||
* The options could also be extended when manually creating a {@link Response} | ||
* object. | ||
* * | ||
* ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview)) | ||
* * | ||
* ``` | ||
* import {BaseResponseOptions, Response} from '@angular/http'; | ||
* * | ||
* var options = new BaseResponseOptions(); | ||
* var res = new Response(options.merge({ | ||
* body: 'Angular', | ||
* headers: new Headers({framework: 'angular'}) | ||
* })); | ||
* console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular | ||
* console.log('res.text():', res.text()); // Angular; | ||
* ``` | ||
* * | ||
*/ | ||
@@ -149,5 +176,14 @@ export var BaseResponseOptions = (function (_super) { | ||
/** @nocollapse */ | ||
BaseResponseOptions.ctorParameters = []; | ||
BaseResponseOptions.ctorParameters = function () { return []; }; | ||
return BaseResponseOptions; | ||
}(ResponseOptions)); | ||
function BaseResponseOptions_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
BaseResponseOptions.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
BaseResponseOptions.ctorParameters; | ||
} | ||
//# sourceMappingURL=base_response_options.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"BaseResponseOptions":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"ResponseOptions":{"__symbolic":"class"},"BaseResponseOptions":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}]}}}} |
@@ -11,4 +11,5 @@ /** | ||
/** | ||
* HTTP request body used by both {@link Request} and {@link Response} | ||
* https://fetch.spec.whatwg.org/#body | ||
* HTTP request body used by both {@link Request} and {@link Response} | ||
* https://fetch.spec.whatwg.org/#body | ||
* @abstract | ||
*/ | ||
@@ -19,7 +20,8 @@ export var Body = (function () { | ||
/** | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
* @return {?} | ||
*/ | ||
Body.prototype.json = function () { | ||
if (typeof this._body === 'string') { | ||
return JSON.parse(this._body); | ||
return JSON.parse(/** @type {?} */ (this._body)); | ||
} | ||
@@ -32,3 +34,4 @@ if (this._body instanceof ArrayBuffer) { | ||
/** | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
* @return {?} | ||
*/ | ||
@@ -40,3 +43,3 @@ Body.prototype.text = function () { | ||
if (this._body instanceof ArrayBuffer) { | ||
return String.fromCharCode.apply(null, new Uint16Array(this._body)); | ||
return String.fromCharCode.apply(null, new Uint16Array(/** @type {?} */ (this._body))); | ||
} | ||
@@ -52,7 +55,8 @@ if (this._body === null) { | ||
/** | ||
* Return the body as an ArrayBuffer | ||
* Return the body as an ArrayBuffer | ||
* @return {?} | ||
*/ | ||
Body.prototype.arrayBuffer = function () { | ||
if (this._body instanceof ArrayBuffer) { | ||
return this._body; | ||
return (this._body); | ||
} | ||
@@ -62,7 +66,8 @@ return stringToArrayBuffer(this.text()); | ||
/** | ||
* Returns the request's body as a Blob, assuming that body exists. | ||
*/ | ||
* Returns the request's body as a Blob, assuming that body exists. | ||
* @return {?} | ||
*/ | ||
Body.prototype.blob = function () { | ||
if (this._body instanceof Blob) { | ||
return this._body; | ||
return (this._body); | ||
} | ||
@@ -76,2 +81,6 @@ if (this._body instanceof ArrayBuffer) { | ||
}()); | ||
function Body_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Body.prototype._body; | ||
} | ||
//# sourceMappingURL=body.js.map |
137
src/enums.js
@@ -1,75 +0,64 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
/** | ||
* Supported http methods. | ||
* @experimental | ||
*/ | ||
export var RequestMethod; | ||
(function (RequestMethod) { | ||
RequestMethod[RequestMethod["Get"] = 0] = "Get"; | ||
RequestMethod[RequestMethod["Post"] = 1] = "Post"; | ||
RequestMethod[RequestMethod["Put"] = 2] = "Put"; | ||
RequestMethod[RequestMethod["Delete"] = 3] = "Delete"; | ||
RequestMethod[RequestMethod["Options"] = 4] = "Options"; | ||
RequestMethod[RequestMethod["Head"] = 5] = "Head"; | ||
RequestMethod[RequestMethod["Patch"] = 6] = "Patch"; | ||
})(RequestMethod || (RequestMethod = {})); | ||
/** | ||
* All possible states in which a connection can be, based on | ||
* [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an | ||
* additional "CANCELLED" state. | ||
* @experimental | ||
*/ | ||
export var ReadyState; | ||
(function (ReadyState) { | ||
ReadyState[ReadyState["Unsent"] = 0] = "Unsent"; | ||
ReadyState[ReadyState["Open"] = 1] = "Open"; | ||
ReadyState[ReadyState["HeadersReceived"] = 2] = "HeadersReceived"; | ||
ReadyState[ReadyState["Loading"] = 3] = "Loading"; | ||
ReadyState[ReadyState["Done"] = 4] = "Done"; | ||
ReadyState[ReadyState["Cancelled"] = 5] = "Cancelled"; | ||
})(ReadyState || (ReadyState = {})); | ||
/** | ||
* Acceptable response types to be associated with a {@link Response}, based on | ||
* [ResponseType](https://fetch.spec.whatwg.org/#responsetype) from the Fetch spec. | ||
* @experimental | ||
*/ | ||
export var ResponseType; | ||
(function (ResponseType) { | ||
ResponseType[ResponseType["Basic"] = 0] = "Basic"; | ||
ResponseType[ResponseType["Cors"] = 1] = "Cors"; | ||
ResponseType[ResponseType["Default"] = 2] = "Default"; | ||
ResponseType[ResponseType["Error"] = 3] = "Error"; | ||
ResponseType[ResponseType["Opaque"] = 4] = "Opaque"; | ||
})(ResponseType || (ResponseType = {})); | ||
/** | ||
* Supported content type to be automatically associated with a {@link Request}. | ||
* @experimental | ||
*/ | ||
export var ContentType; | ||
(function (ContentType) { | ||
ContentType[ContentType["NONE"] = 0] = "NONE"; | ||
ContentType[ContentType["JSON"] = 1] = "JSON"; | ||
ContentType[ContentType["FORM"] = 2] = "FORM"; | ||
ContentType[ContentType["FORM_DATA"] = 3] = "FORM_DATA"; | ||
ContentType[ContentType["TEXT"] = 4] = "TEXT"; | ||
ContentType[ContentType["BLOB"] = 5] = "BLOB"; | ||
ContentType[ContentType["ARRAY_BUFFER"] = 6] = "ARRAY_BUFFER"; | ||
})(ContentType || (ContentType = {})); | ||
/** | ||
* Define which buffer to use to store the response | ||
* @experimental | ||
*/ | ||
export var ResponseContentType; | ||
(function (ResponseContentType) { | ||
ResponseContentType[ResponseContentType["Text"] = 0] = "Text"; | ||
ResponseContentType[ResponseContentType["Json"] = 1] = "Json"; | ||
ResponseContentType[ResponseContentType["ArrayBuffer"] = 2] = "ArrayBuffer"; | ||
ResponseContentType[ResponseContentType["Blob"] = 3] = "Blob"; | ||
})(ResponseContentType || (ResponseContentType = {})); | ||
export var RequestMethod = {}; | ||
RequestMethod.Get = 0; | ||
RequestMethod.Post = 1; | ||
RequestMethod.Put = 2; | ||
RequestMethod.Delete = 3; | ||
RequestMethod.Options = 4; | ||
RequestMethod.Head = 5; | ||
RequestMethod.Patch = 6; | ||
RequestMethod[RequestMethod.Get] = "Get"; | ||
RequestMethod[RequestMethod.Post] = "Post"; | ||
RequestMethod[RequestMethod.Put] = "Put"; | ||
RequestMethod[RequestMethod.Delete] = "Delete"; | ||
RequestMethod[RequestMethod.Options] = "Options"; | ||
RequestMethod[RequestMethod.Head] = "Head"; | ||
RequestMethod[RequestMethod.Patch] = "Patch"; | ||
export var ReadyState = {}; | ||
ReadyState.Unsent = 0; | ||
ReadyState.Open = 1; | ||
ReadyState.HeadersReceived = 2; | ||
ReadyState.Loading = 3; | ||
ReadyState.Done = 4; | ||
ReadyState.Cancelled = 5; | ||
ReadyState[ReadyState.Unsent] = "Unsent"; | ||
ReadyState[ReadyState.Open] = "Open"; | ||
ReadyState[ReadyState.HeadersReceived] = "HeadersReceived"; | ||
ReadyState[ReadyState.Loading] = "Loading"; | ||
ReadyState[ReadyState.Done] = "Done"; | ||
ReadyState[ReadyState.Cancelled] = "Cancelled"; | ||
export var ResponseType = {}; | ||
ResponseType.Basic = 0; | ||
ResponseType.Cors = 1; | ||
ResponseType.Default = 2; | ||
ResponseType.Error = 3; | ||
ResponseType.Opaque = 4; | ||
ResponseType[ResponseType.Basic] = "Basic"; | ||
ResponseType[ResponseType.Cors] = "Cors"; | ||
ResponseType[ResponseType.Default] = "Default"; | ||
ResponseType[ResponseType.Error] = "Error"; | ||
ResponseType[ResponseType.Opaque] = "Opaque"; | ||
export var ContentType = {}; | ||
ContentType.NONE = 0; | ||
ContentType.JSON = 1; | ||
ContentType.FORM = 2; | ||
ContentType.FORM_DATA = 3; | ||
ContentType.TEXT = 4; | ||
ContentType.BLOB = 5; | ||
ContentType.ARRAY_BUFFER = 6; | ||
ContentType[ContentType.NONE] = "NONE"; | ||
ContentType[ContentType.JSON] = "JSON"; | ||
ContentType[ContentType.FORM] = "FORM"; | ||
ContentType[ContentType.FORM_DATA] = "FORM_DATA"; | ||
ContentType[ContentType.TEXT] = "TEXT"; | ||
ContentType[ContentType.BLOB] = "BLOB"; | ||
ContentType[ContentType.ARRAY_BUFFER] = "ARRAY_BUFFER"; | ||
export var ResponseContentType = {}; | ||
ResponseContentType.Text = 0; | ||
ResponseContentType.Json = 1; | ||
ResponseContentType.ArrayBuffer = 2; | ||
ResponseContentType.Blob = 3; | ||
ResponseContentType[ResponseContentType.Text] = "Text"; | ||
ResponseContentType[ResponseContentType.Json] = "Json"; | ||
ResponseContentType[ResponseContentType.ArrayBuffer] = "ArrayBuffer"; | ||
ResponseContentType[ResponseContentType.Blob] = "Blob"; | ||
//# sourceMappingURL=enums.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"RequestMethod":{"Get":0,"Post":1,"Put":2,"Delete":3,"Options":4,"Head":5,"Patch":6},"ReadyState":{"Unsent":0,"Open":1,"HeadersReceived":2,"Loading":3,"Done":4,"Cancelled":5},"ResponseType":{"Basic":0,"Cors":1,"Default":2,"Error":3,"Opaque":4},"ContentType":{"NONE":0,"JSON":1,"FORM":2,"FORM_DATA":3,"TEXT":4,"BLOB":5,"ARRAY_BUFFER":6},"ResponseContentType":{"Text":0,"Json":1,"ArrayBuffer":2,"Blob":3}}} | ||
{"__symbolic":"module","version":2,"metadata":{"RequestMethod":{"Get":0,"Post":1,"Put":2,"Delete":3,"Options":4,"Head":5,"Patch":6},"ReadyState":{"Unsent":0,"Open":1,"HeadersReceived":2,"Loading":3,"Done":4,"Cancelled":5},"ResponseType":{"Basic":0,"Cors":1,"Default":2,"Error":3,"Opaque":4},"ContentType":{"NONE":0,"JSON":1,"FORM":2,"FORM_DATA":3,"TEXT":4,"BLOB":5,"ARRAY_BUFFER":6},"ResponseContentType":{"Text":0,"Json":1,"ArrayBuffer":2,"Blob":3}}} |
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as | ||
* specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class). | ||
* * | ||
* The only known difference between this `Headers` implementation and the spec is the | ||
* lack of an `entries` method. | ||
* * | ||
* ### Example | ||
* * | ||
* ``` | ||
* import {Headers} from '@angular/http'; | ||
* * | ||
* var firstHeaders = new Headers(); | ||
* firstHeaders.append('Content-Type', 'image/jpeg'); | ||
* console.log(firstHeaders.get('Content-Type')) //'image/jpeg' | ||
* * | ||
* // Create headers from Plain Old JavaScript Object | ||
* var secondHeaders = new Headers({ | ||
* 'X-My-Custom-Header': 'Angular' | ||
* }); | ||
* console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular' | ||
* * | ||
* var thirdHeaders = new Headers(secondHeaders); | ||
* console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular' | ||
* ``` | ||
* * | ||
*/ | ||
/** | ||
* Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as | ||
* specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class). | ||
* | ||
* The only known difference between this `Headers` implementation and the spec is the | ||
* lack of an `entries` method. | ||
* | ||
* ### Example | ||
* | ||
* ``` | ||
* import {Headers} from '@angular/http'; | ||
* | ||
* var firstHeaders = new Headers(); | ||
* firstHeaders.append('Content-Type', 'image/jpeg'); | ||
* console.log(firstHeaders.get('Content-Type')) //'image/jpeg' | ||
* | ||
* // Create headers from Plain Old JavaScript Object | ||
* var secondHeaders = new Headers({ | ||
* 'X-My-Custom-Header': 'Angular' | ||
* }); | ||
* console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular' | ||
* | ||
* var thirdHeaders = new Headers(secondHeaders); | ||
* console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular' | ||
* ``` | ||
* | ||
* @experimental | ||
*/ | ||
export var Headers = (function () { | ||
// TODO(vicb): any -> string|string[] | ||
/** | ||
* @param {?=} headers | ||
*/ | ||
function Headers(headers) { | ||
@@ -60,11 +54,13 @@ var _this = this; | ||
/** | ||
* Returns a new Headers instance from the given DOMString of Response Headers | ||
* Returns a new Headers instance from the given DOMString of Response Headers | ||
* @param {?} headersString | ||
* @return {?} | ||
*/ | ||
Headers.fromResponseHeaderString = function (headersString) { | ||
var headers = new Headers(); | ||
var /** @type {?} */ headers = new Headers(); | ||
headersString.split('\n').forEach(function (line) { | ||
var index = line.indexOf(':'); | ||
var /** @type {?} */ index = line.indexOf(':'); | ||
if (index > 0) { | ||
var name_1 = line.slice(0, index); | ||
var value = line.slice(index + 1).trim(); | ||
var /** @type {?} */ name_1 = line.slice(0, index); | ||
var /** @type {?} */ value = line.slice(index + 1).trim(); | ||
headers.set(name_1, value); | ||
@@ -76,6 +72,9 @@ } | ||
/** | ||
* Appends a header to existing list of header values for a given header name. | ||
* Appends a header to existing list of header values for a given header name. | ||
* @param {?} name | ||
* @param {?} value | ||
* @return {?} | ||
*/ | ||
Headers.prototype.append = function (name, value) { | ||
var values = this.getAll(name); | ||
var /** @type {?} */ values = this.getAll(name); | ||
if (values === null) { | ||
@@ -89,9 +88,15 @@ this.set(name, value); | ||
/** | ||
* Deletes all header values for the given name. | ||
* Deletes all header values for the given name. | ||
* @param {?} name | ||
* @return {?} | ||
*/ | ||
Headers.prototype.delete = function (name) { | ||
var lcName = name.toLowerCase(); | ||
var /** @type {?} */ lcName = name.toLowerCase(); | ||
this._normalizedNames.delete(lcName); | ||
this._headers.delete(lcName); | ||
}; | ||
/** | ||
* @param {?} fn | ||
* @return {?} | ||
*/ | ||
Headers.prototype.forEach = function (fn) { | ||
@@ -102,6 +107,8 @@ var _this = this; | ||
/** | ||
* Returns first header that matches given name. | ||
* Returns first header that matches given name. | ||
* @param {?} name | ||
* @return {?} | ||
*/ | ||
Headers.prototype.get = function (name) { | ||
var values = this.getAll(name); | ||
var /** @type {?} */ values = this.getAll(name); | ||
if (values === null) { | ||
@@ -113,11 +120,17 @@ return null; | ||
/** | ||
* Checks for existence of header by given name. | ||
* Checks for existence of header by given name. | ||
* @param {?} name | ||
* @return {?} | ||
*/ | ||
Headers.prototype.has = function (name) { return this._headers.has(name.toLowerCase()); }; | ||
/** | ||
* Returns the names of the headers | ||
* Returns the names of the headers | ||
* @return {?} | ||
*/ | ||
Headers.prototype.keys = function () { return Array.from(this._normalizedNames.values()); }; | ||
/** | ||
* Sets or overrides header value for given name. | ||
* Sets or overrides header value for given name. | ||
* @param {?} name | ||
* @param {?} value | ||
* @return {?} | ||
*/ | ||
@@ -136,14 +149,14 @@ Headers.prototype.set = function (name, value) { | ||
/** | ||
* Returns values of all headers. | ||
* Returns values of all headers. | ||
* @return {?} | ||
*/ | ||
Headers.prototype.values = function () { return Array.from(this._headers.values()); }; | ||
/** | ||
* Returns string of all headers. | ||
* @return {?} | ||
*/ | ||
// TODO(vicb): returns {[name: string]: string[]} | ||
Headers.prototype.toJSON = function () { | ||
var _this = this; | ||
var serialized = {}; | ||
var /** @type {?} */ serialized = {}; | ||
this._headers.forEach(function (values, name) { | ||
var split = []; | ||
var /** @type {?} */ split = []; | ||
values.forEach(function (v) { return split.push.apply(split, v.split(',')); }); | ||
@@ -155,3 +168,5 @@ serialized[_this._normalizedNames.get(name)] = split; | ||
/** | ||
* Returns list of header values for a given name. | ||
* Returns list of header values for a given name. | ||
* @param {?} name | ||
* @return {?} | ||
*/ | ||
@@ -162,7 +177,12 @@ Headers.prototype.getAll = function (name) { | ||
/** | ||
* This method is not implemented. | ||
* This method is not implemented. | ||
* @return {?} | ||
*/ | ||
Headers.prototype.entries = function () { throw new Error('"entries" method is not implemented on Headers class'); }; | ||
/** | ||
* @param {?} name | ||
* @return {?} | ||
*/ | ||
Headers.prototype.mayBeSetNormalizedName = function (name) { | ||
var lcName = name.toLowerCase(); | ||
var /** @type {?} */ lcName = name.toLowerCase(); | ||
if (!this._normalizedNames.has(lcName)) { | ||
@@ -174,2 +194,8 @@ this._normalizedNames.set(lcName, name); | ||
}()); | ||
function Headers_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Headers.prototype._headers; | ||
/** @type {?} */ | ||
Headers.prototype._normalizedNames; | ||
} | ||
//# sourceMappingURL=headers.js.map |
@@ -17,8 +17,21 @@ /** | ||
import { XSRFStrategy } from './interfaces'; | ||
/** | ||
* @return {?} | ||
*/ | ||
export function _createDefaultCookieXSRFStrategy() { | ||
return new CookieXSRFStrategy(); | ||
} | ||
/** | ||
* @param {?} xhrBackend | ||
* @param {?} requestOptions | ||
* @return {?} | ||
*/ | ||
export function httpFactory(xhrBackend, requestOptions) { | ||
return new Http(xhrBackend, requestOptions); | ||
} | ||
/** | ||
* @param {?} jsonpBackend | ||
* @param {?} requestOptions | ||
* @return {?} | ||
*/ | ||
export function jsonpFactory(jsonpBackend, requestOptions) { | ||
@@ -28,5 +41,4 @@ return new Jsonp(jsonpBackend, requestOptions); | ||
/** | ||
* The module that includes http's providers | ||
* | ||
* @experimental | ||
* The module that includes http's providers | ||
* * | ||
*/ | ||
@@ -51,9 +63,17 @@ export var HttpModule = (function () { | ||
/** @nocollapse */ | ||
HttpModule.ctorParameters = []; | ||
HttpModule.ctorParameters = function () { return []; }; | ||
return HttpModule; | ||
}()); | ||
function HttpModule_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
HttpModule.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
HttpModule.ctorParameters; | ||
} | ||
/** | ||
* The module that includes jsonp's providers | ||
* | ||
* @experimental | ||
* The module that includes jsonp's providers | ||
* * | ||
*/ | ||
@@ -77,5 +97,14 @@ export var JsonpModule = (function () { | ||
/** @nocollapse */ | ||
JsonpModule.ctorParameters = []; | ||
JsonpModule.ctorParameters = function () { return []; }; | ||
return JsonpModule; | ||
}()); | ||
function JsonpModule_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
JsonpModule.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
JsonpModule.ctorParameters; | ||
} | ||
//# sourceMappingURL=http_module.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"_createDefaultCookieXSRFStrategy":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./backends/xhr_backend","name":"CookieXSRFStrategy"}}},"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"jsonpFactory":{"__symbolic":"function","parameters":["jsonpBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./http","name":"Jsonp"},"arguments":[{"__symbolic":"reference","name":"jsonpBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","module":"./http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./interfaces","name":"XSRFStrategy"},"useFactory":{"__symbolic":"reference","name":"_createDefaultCookieXSRFStrategy"}}]}]}]},"JsonpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","module":"./http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend_"}}]}]}]}}} | ||
{"__symbolic":"module","version":2,"metadata":{"_createDefaultCookieXSRFStrategy":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./backends/xhr_backend","name":"CookieXSRFStrategy"}}},"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"jsonpFactory":{"__symbolic":"function","parameters":["jsonpBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./http","name":"Jsonp"},"arguments":[{"__symbolic":"reference","name":"jsonpBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","module":"./http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./interfaces","name":"XSRFStrategy"},"useFactory":{"__symbolic":"reference","name":"_createDefaultCookieXSRFStrategy"}}]}]}]},"JsonpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","module":"./http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./backends/jsonp_backend","name":"JSONPBackend_"}}]}]}]}}} |
@@ -9,2 +9,6 @@ /** | ||
import { RequestMethod } from './enums'; | ||
/** | ||
* @param {?} method | ||
* @return {?} | ||
*/ | ||
export function normalizeMethodName(method) { | ||
@@ -31,3 +35,7 @@ if (typeof method !== 'string') | ||
} | ||
export var isSuccess = function (status) { return (status >= 200 && status < 300); }; | ||
export var /** @type {?} */ isSuccess = function (status) { return (status >= 200 && status < 300); }; | ||
/** | ||
* @param {?} xhr | ||
* @return {?} | ||
*/ | ||
export function getResponseURL(xhr) { | ||
@@ -42,5 +50,9 @@ if ('responseURL' in xhr) { | ||
} | ||
/** | ||
* @param {?} input | ||
* @return {?} | ||
*/ | ||
export function stringToArrayBuffer(input) { | ||
var view = new Uint16Array(input.length); | ||
for (var i = 0, strLen = input.length; i < strLen; i++) { | ||
var /** @type {?} */ view = new Uint16Array(input.length); | ||
for (var /** @type {?} */ i = 0, /** @type {?} */ strLen = input.length; i < strLen; i++) { | ||
view[i] = input.charCodeAt(i); | ||
@@ -47,0 +59,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":32,"character":25}}} | ||
{"__symbolic":"module","version":2,"metadata":{"normalizeMethodName":{"__symbolic":"function"},"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":32,"character":25},"getResponseURL":{"__symbolic":"function"},"stringToArrayBuffer":{"__symbolic":"function"}}} |
249
src/http.js
@@ -18,7 +18,19 @@ /** | ||
import { Request } from './static_request'; | ||
/** | ||
* @param {?} backend | ||
* @param {?} request | ||
* @return {?} | ||
*/ | ||
function httpRequest(backend, request) { | ||
return backend.createConnection(request).response; | ||
} | ||
/** | ||
* @param {?} defaultOpts | ||
* @param {?} providedOpts | ||
* @param {?} method | ||
* @param {?} url | ||
* @return {?} | ||
*/ | ||
function mergeOptions(defaultOpts, providedOpts, method, url) { | ||
var newOptions = defaultOpts; | ||
var /** @type {?} */ newOptions = defaultOpts; | ||
if (providedOpts) { | ||
@@ -39,62 +51,64 @@ // Hack so Dart can used named parameters | ||
/** | ||
* Performs http requests using `XMLHttpRequest` as the default backend. | ||
* | ||
* `Http` is available as an injectable class, with methods to perform http requests. Calling | ||
* `request` returns an `Observable` which will emit a single {@link Response} when a | ||
* response is received. | ||
* | ||
* ### Example | ||
* | ||
* ```typescript | ||
* import {Http, HTTP_PROVIDERS} from '@angular/http'; | ||
* import 'rxjs/add/operator/map' | ||
* @Component({ | ||
* selector: 'http-app', | ||
* viewProviders: [HTTP_PROVIDERS], | ||
* templateUrl: 'people.html' | ||
* }) | ||
* class PeopleComponent { | ||
* constructor(http: Http) { | ||
* http.get('people.json') | ||
* // Call map on the response observable to get the parsed people object | ||
* .map(res => res.json()) | ||
* // Subscribe to the observable to get the parsed people object and attach it to the | ||
* // component | ||
* .subscribe(people => this.people = people); | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* | ||
* ### Example | ||
* | ||
* ``` | ||
* http.get('people.json').subscribe((res:Response) => this.people = res.json()); | ||
* ``` | ||
* | ||
* The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" ( | ||
* {@link XHRBackend} in this case), which could be mocked with dependency injection by replacing | ||
* the {@link XHRBackend} provider, as in the following example: | ||
* | ||
* ### Example | ||
* | ||
* ```typescript | ||
* import {BaseRequestOptions, Http} from '@angular/http'; | ||
* import {MockBackend} from '@angular/http/testing'; | ||
* var injector = Injector.resolveAndCreate([ | ||
* BaseRequestOptions, | ||
* MockBackend, | ||
* {provide: Http, useFactory: | ||
* function(backend, defaultOptions) { | ||
* return new Http(backend, defaultOptions); | ||
* }, | ||
* deps: [MockBackend, BaseRequestOptions]} | ||
* ]); | ||
* var http = injector.get(Http); | ||
* http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res)); | ||
* ``` | ||
* | ||
* @experimental | ||
* Performs http requests using `XMLHttpRequest` as the default backend. | ||
* * | ||
* `Http` is available as an injectable class, with methods to perform http requests. Calling | ||
* `request` returns an `Observable` which will emit a single {@link Response} when a | ||
* response is received. | ||
* * | ||
* ### Example | ||
* * | ||
* ```typescript | ||
* import {Http, HTTP_PROVIDERS} from '@angular/http'; | ||
* import 'rxjs/add/operator/map' | ||
* selector: 'http-app', | ||
* viewProviders: [HTTP_PROVIDERS], | ||
* templateUrl: 'people.html' | ||
* }) | ||
* class PeopleComponent { | ||
* constructor(http: Http) { | ||
* http.get('people.json') | ||
* // Call map on the response observable to get the parsed people object | ||
* .map(res => res.json()) | ||
* // Subscribe to the observable to get the parsed people object and attach it to the | ||
* // component | ||
* .subscribe(people => this.people = people); | ||
* } | ||
* } | ||
* ``` | ||
* * | ||
* * | ||
* ### Example | ||
* * | ||
* ``` | ||
* http.get('people.json').subscribe((res:Response) => this.people = res.json()); | ||
* ``` | ||
* * | ||
* The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" ( | ||
* {@link XHRBackend} in this case), which could be mocked with dependency injection by replacing | ||
* the {@link XHRBackend} provider, as in the following example: | ||
* * | ||
* ### Example | ||
* * | ||
* ```typescript | ||
* import {BaseRequestOptions, Http} from '@angular/http'; | ||
* import {MockBackend} from '@angular/http/testing'; | ||
* var injector = Injector.resolveAndCreate([ | ||
* BaseRequestOptions, | ||
* MockBackend, | ||
* {provide: Http, useFactory: | ||
* function(backend, defaultOptions) { | ||
* return new Http(backend, defaultOptions); | ||
* }, | ||
* deps: [MockBackend, BaseRequestOptions]} | ||
* ]); | ||
* var http = injector.get(Http); | ||
* http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res)); | ||
* ``` | ||
* * | ||
*/ | ||
export var Http = (function () { | ||
/** | ||
* @param {?} _backend | ||
* @param {?} _defaultOptions | ||
*/ | ||
function Http(_backend, _defaultOptions) { | ||
@@ -105,11 +119,14 @@ this._backend = _backend; | ||
/** | ||
* Performs any type of http request. First argument is required, and can either be a url or | ||
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} | ||
* object can be provided as the 2nd argument. The options object will be merged with the values | ||
* of {@link BaseRequestOptions} before performing the request. | ||
* Performs any type of http request. First argument is required, and can either be a url or | ||
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} | ||
* object can be provided as the 2nd argument. The options object will be merged with the values | ||
* of {@link BaseRequestOptions} before performing the request. | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
Http.prototype.request = function (url, options) { | ||
var responseObservable; | ||
var /** @type {?} */ responseObservable; | ||
if (typeof url === 'string') { | ||
responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url))); | ||
responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url)))); | ||
} | ||
@@ -125,3 +142,6 @@ else if (url instanceof Request) { | ||
/** | ||
* Performs a request with `get` http method. | ||
* Performs a request with `get` http method. | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -132,3 +152,7 @@ Http.prototype.get = function (url, options) { | ||
/** | ||
* Performs a request with `post` http method. | ||
* Performs a request with `post` http method. | ||
* @param {?} url | ||
* @param {?} body | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -139,3 +163,7 @@ Http.prototype.post = function (url, body, options) { | ||
/** | ||
* Performs a request with `put` http method. | ||
* Performs a request with `put` http method. | ||
* @param {?} url | ||
* @param {?} body | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -146,3 +174,6 @@ Http.prototype.put = function (url, body, options) { | ||
/** | ||
* Performs a request with `delete` http method. | ||
* Performs a request with `delete` http method. | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -153,3 +184,7 @@ Http.prototype.delete = function (url, options) { | ||
/** | ||
* Performs a request with `patch` http method. | ||
* Performs a request with `patch` http method. | ||
* @param {?} url | ||
* @param {?} body | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -160,3 +195,6 @@ Http.prototype.patch = function (url, body, options) { | ||
/** | ||
* Performs a request with `head` http method. | ||
* Performs a request with `head` http method. | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -167,3 +205,6 @@ Http.prototype.head = function (url, options) { | ||
/** | ||
* Performs a request with `options` http method. | ||
* Performs a request with `options` http method. | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
@@ -177,8 +218,21 @@ Http.prototype.options = function (url, options) { | ||
/** @nocollapse */ | ||
Http.ctorParameters = [ | ||
Http.ctorParameters = function () { return [ | ||
{ type: ConnectionBackend, }, | ||
{ type: RequestOptions, }, | ||
]; | ||
]; }; | ||
return Http; | ||
}()); | ||
function Http_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Http.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
Http.ctorParameters; | ||
/** @type {?} */ | ||
Http.prototype._backend; | ||
/** @type {?} */ | ||
Http.prototype._defaultOptions; | ||
} | ||
/** | ||
@@ -189,2 +243,6 @@ * @experimental | ||
__extends(Jsonp, _super); | ||
/** | ||
* @param {?} backend | ||
* @param {?} defaultOptions | ||
*/ | ||
function Jsonp(backend, defaultOptions) { | ||
@@ -194,20 +252,22 @@ _super.call(this, backend, defaultOptions); | ||
/** | ||
* Performs any type of http request. First argument is required, and can either be a url or | ||
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} | ||
* object can be provided as the 2nd argument. The options object will be merged with the values | ||
* of {@link BaseRequestOptions} before performing the request. | ||
* | ||
* @security Regular XHR is the safest alternative to JSONP for most applications, and is | ||
* supported by all current browsers. Because JSONP creates a `<script>` element with | ||
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted | ||
* source could expose your application to XSS risks. Data exposed by JSONP may also be | ||
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for | ||
* future security issues (e.g. content sniffing). For more detail, see the | ||
* [Security Guide](http://g.co/ng/security). | ||
* Performs any type of http request. First argument is required, and can either be a url or | ||
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} | ||
* object can be provided as the 2nd argument. The options object will be merged with the values | ||
* of {@link BaseRequestOptions} before performing the request. | ||
* * | ||
* supported by all current browsers. Because JSONP creates a `<script>` element with | ||
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted | ||
* source could expose your application to XSS risks. Data exposed by JSONP may also be | ||
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for | ||
* future security issues (e.g. content sniffing). For more detail, see the | ||
* [Security Guide](http://g.co/ng/security). | ||
* @param {?} url | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
Jsonp.prototype.request = function (url, options) { | ||
var responseObservable; | ||
var /** @type {?} */ responseObservable; | ||
if (typeof url === 'string') { | ||
url = | ||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)); | ||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url))); | ||
} | ||
@@ -229,8 +289,17 @@ if (url instanceof Request) { | ||
/** @nocollapse */ | ||
Jsonp.ctorParameters = [ | ||
Jsonp.ctorParameters = function () { return [ | ||
{ type: ConnectionBackend, }, | ||
{ type: RequestOptions, }, | ||
]; | ||
]; }; | ||
return Jsonp; | ||
}(Http)); | ||
function Jsonp_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Jsonp.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
Jsonp.ctorParameters; | ||
} | ||
//# sourceMappingURL=http.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"Http":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./interfaces","name":"ConnectionBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]}],"request":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"post":[{"__symbolic":"method"}],"put":[{"__symbolic":"method"}],"delete":[{"__symbolic":"method"}],"patch":[{"__symbolic":"method"}],"head":[{"__symbolic":"method"}],"options":[{"__symbolic":"method"}]}},"Jsonp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./interfaces","name":"ConnectionBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]}],"request":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"Http":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./interfaces","name":"ConnectionBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]}],"request":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"post":[{"__symbolic":"method"}],"put":[{"__symbolic":"method"}],"delete":[{"__symbolic":"method"}],"patch":[{"__symbolic":"method"}],"head":[{"__symbolic":"method"}],"options":[{"__symbolic":"method"}]}},"Jsonp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./interfaces","name":"ConnectionBackend"},{"__symbolic":"reference","module":"./base_request_options","name":"RequestOptions"}]}],"request":[{"__symbolic":"method"}]}}}} |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./backends/browser_xhr","export":["BrowserXhr"]},{"from":"./backends/jsonp_backend","export":["JSONPBackend","JSONPConnection"]},{"from":"./backends/xhr_backend","export":["CookieXSRFStrategy","XHRBackend","XHRConnection"]},{"from":"./base_request_options","export":["BaseRequestOptions","RequestOptions"]},{"from":"./base_response_options","export":["BaseResponseOptions","ResponseOptions"]},{"from":"./enums","export":["ReadyState","RequestMethod","ResponseContentType","ResponseType"]},{"from":"./headers","export":["Headers"]},{"from":"./http","export":["Http","Jsonp"]},{"from":"./http_module","export":["HttpModule","JsonpModule"]},{"from":"./interfaces","export":["Connection","ConnectionBackend","RequestOptionsArgs","ResponseOptionsArgs","XSRFStrategy"]},{"from":"./static_request","export":["Request"]},{"from":"./static_response","export":["Response"]},{"from":"./url_search_params","export":["QueryEncoder","URLSearchParams"]}]} | ||
{"__symbolic":"module","version":2,"metadata":{},"exports":[{"from":"./backends/browser_xhr","export":["BrowserXhr"]},{"from":"./backends/jsonp_backend","export":["JSONPBackend","JSONPConnection"]},{"from":"./backends/xhr_backend","export":["CookieXSRFStrategy","XHRBackend","XHRConnection"]},{"from":"./base_request_options","export":["BaseRequestOptions","RequestOptions"]},{"from":"./base_response_options","export":["BaseResponseOptions","ResponseOptions"]},{"from":"./enums","export":["ReadyState","RequestMethod","ResponseContentType","ResponseType"]},{"from":"./headers","export":["Headers"]},{"from":"./http","export":["Http","Jsonp"]},{"from":"./http_module","export":["HttpModule","JsonpModule"]},{"from":"./interfaces","export":["Connection","ConnectionBackend","RequestOptionsArgs","ResponseOptionsArgs","XSRFStrategy"]},{"from":"./static_request","export":["Request"]},{"from":"./static_response","export":["Response"]},{"from":"./url_search_params","export":["QueryEncoder","URLSearchParams"]}]} |
@@ -9,8 +9,8 @@ /** | ||
/** | ||
* Abstract class from which real backends are derived. | ||
* | ||
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given | ||
* {@link Request}. | ||
* | ||
* @experimental | ||
* Abstract class from which real backends are derived. | ||
* * | ||
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given | ||
* {@link Request}. | ||
* * | ||
* @abstract | ||
*/ | ||
@@ -20,8 +20,14 @@ export var ConnectionBackend = (function () { | ||
} | ||
/** | ||
* @abstract | ||
* @param {?} request | ||
* @return {?} | ||
*/ | ||
ConnectionBackend.prototype.createConnection = function (request) { }; | ||
return ConnectionBackend; | ||
}()); | ||
/** | ||
* Abstract class from which real connections are derived. | ||
* | ||
* @experimental | ||
* Abstract class from which real connections are derived. | ||
* * | ||
* @abstract | ||
*/ | ||
@@ -33,6 +39,14 @@ export var Connection = (function () { | ||
}()); | ||
function Connection_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Connection.prototype.readyState; | ||
/** @type {?} */ | ||
Connection.prototype.request; | ||
/** @type {?} */ | ||
Connection.prototype.response; | ||
} | ||
/** | ||
* An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request. | ||
* | ||
* @experimental | ||
* An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request. | ||
* * | ||
* @abstract | ||
*/ | ||
@@ -42,4 +56,10 @@ export var XSRFStrategy = (function () { | ||
} | ||
/** | ||
* @abstract | ||
* @param {?} req | ||
* @return {?} | ||
*/ | ||
XSRFStrategy.prototype.configureRequest = function (req) { }; | ||
return XSRFStrategy; | ||
}()); | ||
//# sourceMappingURL=interfaces.js.map |
@@ -18,44 +18,44 @@ /** | ||
import { URLSearchParams } from './url_search_params'; | ||
// TODO(jeffbcross): properly implement body accessors | ||
/** | ||
* Creates `Request` instances from provided values. | ||
* | ||
* The Request's interface is inspired by the Request constructor defined in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#request-class), | ||
* but is considered a static value whose body can be accessed many times. There are other | ||
* differences in the implementation, but this is the most significant. | ||
* | ||
* `Request` instances are typically created by higher-level classes, like {@link Http} and | ||
* {@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances. | ||
* One such example is when creating services that wrap higher-level services, like {@link Http}, | ||
* where it may be useful to generate a `Request` with arbitrary headers and search params. | ||
* | ||
* ```typescript | ||
* import {Injectable, Injector} from '@angular/core'; | ||
* import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '@angular/http'; | ||
* | ||
* @Injectable() | ||
* class AutoAuthenticator { | ||
* constructor(public http:Http) {} | ||
* request(url:string) { | ||
* return this.http.request(new Request({ | ||
* method: RequestMethod.Get, | ||
* url: url, | ||
* search: 'password=123' | ||
* })); | ||
* } | ||
* } | ||
* | ||
* var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]); | ||
* var authenticator = injector.get(AutoAuthenticator); | ||
* authenticator.request('people.json').subscribe(res => { | ||
* //URL should have included '?password=123' | ||
* console.log('people', res.json()); | ||
* }); | ||
* ``` | ||
* | ||
* @experimental | ||
* Creates `Request` instances from provided values. | ||
* * | ||
* The Request's interface is inspired by the Request constructor defined in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#request-class), | ||
* but is considered a static value whose body can be accessed many times. There are other | ||
* differences in the implementation, but this is the most significant. | ||
* * | ||
* `Request` instances are typically created by higher-level classes, like {@link Http} and | ||
* {@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances. | ||
* One such example is when creating services that wrap higher-level services, like {@link Http}, | ||
* where it may be useful to generate a `Request` with arbitrary headers and search params. | ||
* * | ||
* ```typescript | ||
* import {Injectable, Injector} from '@angular/core'; | ||
* import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '@angular/http'; | ||
* * | ||
* class AutoAuthenticator { | ||
* constructor(public http:Http) {} | ||
* request(url:string) { | ||
* return this.http.request(new Request({ | ||
* method: RequestMethod.Get, | ||
* url: url, | ||
* search: 'password=123' | ||
* })); | ||
* } | ||
* } | ||
* * | ||
* var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]); | ||
* var authenticator = injector.get(AutoAuthenticator); | ||
* authenticator.request('people.json').subscribe(res => { | ||
* //URL should have included '?password=123' | ||
* console.log('people', res.json()); | ||
* }); | ||
* ``` | ||
* * | ||
*/ | ||
export var Request = (function (_super) { | ||
__extends(Request, _super); | ||
/** | ||
* @param {?} requestOptions | ||
*/ | ||
function Request(requestOptions) { | ||
@@ -87,3 +87,4 @@ _super.call(this); | ||
/** | ||
* Returns the content type enum based on header options. | ||
* Returns the content type enum based on header options. | ||
* @return {?} | ||
*/ | ||
@@ -108,3 +109,4 @@ Request.prototype.detectContentType = function () { | ||
/** | ||
* Returns the content type of request's body based on its type. | ||
* Returns the content type of request's body based on its type. | ||
* @return {?} | ||
*/ | ||
@@ -135,4 +137,5 @@ Request.prototype.detectContentTypeFromBody = function () { | ||
/** | ||
* Returns the request's body according to its type. If body is undefined, return | ||
* null. | ||
* Returns the request's body according to its type. If body is undefined, return | ||
* null. | ||
* @return {?} | ||
*/ | ||
@@ -159,7 +162,39 @@ Request.prototype.getBody = function () { | ||
}(Body)); | ||
var noop = function () { }; | ||
var w = typeof window == 'object' ? window : noop; | ||
var FormData = w['FormData'] || noop; | ||
var Blob = w['Blob'] || noop; | ||
var ArrayBuffer = w['ArrayBuffer'] || noop; | ||
function Request_tsickle_Closure_declarations() { | ||
/** | ||
* Http method with which to perform the request. | ||
* @type {?} | ||
*/ | ||
Request.prototype.method; | ||
/** | ||
* {@link Headers} instance | ||
* @type {?} | ||
*/ | ||
Request.prototype.headers; | ||
/** | ||
* Url of the remote resource | ||
* @type {?} | ||
*/ | ||
Request.prototype.url; | ||
/** | ||
* Type of the request body * | ||
* @type {?} | ||
*/ | ||
Request.prototype.contentType; | ||
/** | ||
* Enable use credentials | ||
* @type {?} | ||
*/ | ||
Request.prototype.withCredentials; | ||
/** | ||
* Buffer to store the response | ||
* @type {?} | ||
*/ | ||
Request.prototype.responseType; | ||
} | ||
var /** @type {?} */ noop = function () { }; | ||
var /** @type {?} */ w = typeof window == 'object' ? window : noop; | ||
var /** @type {?} */ FormData = ((w) /** TODO #9100 */)['FormData'] || noop; | ||
var /** @type {?} */ Blob = ((w) /** TODO #9100 */)['Blob'] || noop; | ||
var /** @type {?} */ ArrayBuffer = ((w) /** TODO #9100 */)['ArrayBuffer'] || noop; | ||
//# sourceMappingURL=static_request.js.map |
@@ -15,23 +15,25 @@ /** | ||
/** | ||
* Creates `Response` instances from provided values. | ||
* | ||
* Though this object isn't | ||
* usually instantiated by end-users, it is the primary object interacted with when it comes time to | ||
* add data to a view. | ||
* | ||
* ### Example | ||
* | ||
* ``` | ||
* http.request('my-friends.txt').subscribe(response => this.friends = response.text()); | ||
* ``` | ||
* | ||
* The Response's interface is inspired by the Response constructor defined in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body | ||
* can be accessed many times. There are other differences in the implementation, but this is the | ||
* most significant. | ||
* | ||
* @experimental | ||
* Creates `Response` instances from provided values. | ||
* * | ||
* Though this object isn't | ||
* usually instantiated by end-users, it is the primary object interacted with when it comes time to | ||
* add data to a view. | ||
* * | ||
* ### Example | ||
* * | ||
* ``` | ||
* http.request('my-friends.txt').subscribe(response => this.friends = response.text()); | ||
* ``` | ||
* * | ||
* The Response's interface is inspired by the Response constructor defined in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body | ||
* can be accessed many times. There are other differences in the implementation, but this is the | ||
* most significant. | ||
* * | ||
*/ | ||
export var Response = (function (_super) { | ||
__extends(Response, _super); | ||
/** | ||
* @param {?} responseOptions | ||
*/ | ||
function Response(responseOptions) { | ||
@@ -47,2 +49,5 @@ _super.call(this); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
Response.prototype.toString = function () { | ||
@@ -53,2 +58,59 @@ return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url; | ||
}(Body)); | ||
function Response_tsickle_Closure_declarations() { | ||
/** | ||
* One of "basic", "cors", "default", "error, or "opaque". | ||
* * | ||
* Defaults to "default". | ||
* @type {?} | ||
*/ | ||
Response.prototype.type; | ||
/** | ||
* True if the response's status is within 200-299 | ||
* @type {?} | ||
*/ | ||
Response.prototype.ok; | ||
/** | ||
* URL of response. | ||
* * | ||
* Defaults to empty string. | ||
* @type {?} | ||
*/ | ||
Response.prototype.url; | ||
/** | ||
* Status code returned by server. | ||
* * | ||
* Defaults to 200. | ||
* @type {?} | ||
*/ | ||
Response.prototype.status; | ||
/** | ||
* Text representing the corresponding reason phrase to the `status`, as defined in [ietf rfc 2616 | ||
* section 6.1.1](https://tools.ietf.org/html/rfc2616#section-6.1.1) | ||
* * | ||
* Defaults to "OK" | ||
* @type {?} | ||
*/ | ||
Response.prototype.statusText; | ||
/** | ||
* Non-standard property | ||
* * | ||
* Denotes how many of the response body's bytes have been loaded, for example if the response is | ||
* the result of a progress event. | ||
* @type {?} | ||
*/ | ||
Response.prototype.bytesLoaded; | ||
/** | ||
* Non-standard property | ||
* * | ||
* Denotes how many bytes are expected in the final response body. | ||
* @type {?} | ||
*/ | ||
Response.prototype.totalBytes; | ||
/** | ||
* Headers object based on the `Headers` class in the [Fetch | ||
* Spec](https://fetch.spec.whatwg.org/#headers-class). | ||
* @type {?} | ||
*/ | ||
Response.prototype.headers; | ||
} | ||
//# sourceMappingURL=static_response.js.map |
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* @license undefined | ||
* Copyright Google Inc. All Rights Reserved. | ||
* * | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* @param {?=} rawParams | ||
* @return {?} | ||
*/ | ||
function paramParser(rawParams) { | ||
if (rawParams === void 0) { rawParams = ''; } | ||
var map = new Map(); | ||
var /** @type {?} */ map = new Map(); | ||
if (rawParams.length > 0) { | ||
var params = rawParams.split('&'); | ||
var /** @type {?} */ params = rawParams.split('&'); | ||
params.forEach(function (param) { | ||
var eqIdx = param.indexOf('='); | ||
var /** @type {?} */ eqIdx = param.indexOf('='); | ||
var _a = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)], key = _a[0], val = _a[1]; | ||
var list = map.get(key) || []; | ||
var /** @type {?} */ list = map.get(key) || []; | ||
list.push(val); | ||
@@ -24,11 +26,23 @@ map.set(key, list); | ||
/** | ||
* @experimental | ||
**/ | ||
* * | ||
*/ | ||
export var QueryEncoder = (function () { | ||
function QueryEncoder() { | ||
} | ||
/** | ||
* @param {?} k | ||
* @return {?} | ||
*/ | ||
QueryEncoder.prototype.encodeKey = function (k) { return standardEncoding(k); }; | ||
/** | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
QueryEncoder.prototype.encodeValue = function (v) { return standardEncoding(v); }; | ||
return QueryEncoder; | ||
}()); | ||
/** | ||
* @param {?} v | ||
* @return {?} | ||
*/ | ||
function standardEncoding(v) { | ||
@@ -47,37 +61,40 @@ return encodeURIComponent(v) | ||
/** | ||
* Map-like representation of url search parameters, based on | ||
* [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard, | ||
* with several extensions for merging URLSearchParams objects: | ||
* - setAll() | ||
* - appendAll() | ||
* - replaceAll() | ||
* | ||
* This class accepts an optional second parameter of ${@link QueryEncoder}, | ||
* which is used to serialize parameters before making a request. By default, | ||
* `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`, | ||
* and then un-encodes certain characters that are allowed to be part of the query | ||
* according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986. | ||
* | ||
* These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /` | ||
* | ||
* If the set of allowed query characters is not acceptable for a particular backend, | ||
* `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams. | ||
* | ||
* ``` | ||
* import {URLSearchParams, QueryEncoder} from '@angular/http'; | ||
* class MyQueryEncoder extends QueryEncoder { | ||
* encodeKey(k: string): string { | ||
* return myEncodingFunction(k); | ||
* } | ||
* | ||
* encodeValue(v: string): string { | ||
* return myEncodingFunction(v); | ||
* } | ||
* } | ||
* | ||
* let params = new URLSearchParams('', new MyQueryEncoder()); | ||
* ``` | ||
* @experimental | ||
* Map-like representation of url search parameters, based on | ||
* [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard, | ||
* with several extensions for merging URLSearchParams objects: | ||
* - setAll() | ||
* - appendAll() | ||
* - replaceAll() | ||
* * | ||
* This class accepts an optional second parameter of ${@link QueryEncoder}, | ||
* which is used to serialize parameters before making a request. By default, | ||
* `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`, | ||
* and then un-encodes certain characters that are allowed to be part of the query | ||
* according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986. | ||
* * | ||
* These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /` | ||
* * | ||
* If the set of allowed query characters is not acceptable for a particular backend, | ||
* `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams. | ||
* * | ||
* ``` | ||
* import {URLSearchParams, QueryEncoder} from '@angular/http'; | ||
* class MyQueryEncoder extends QueryEncoder { | ||
* encodeKey(k: string): string { | ||
* return myEncodingFunction(k); | ||
* } | ||
* * | ||
* encodeValue(v: string): string { | ||
* return myEncodingFunction(v); | ||
* } | ||
* } | ||
* * | ||
* let params = new URLSearchParams('', new MyQueryEncoder()); | ||
* ``` | ||
*/ | ||
export var URLSearchParams = (function () { | ||
/** | ||
* @param {?=} rawParams | ||
* @param {?=} queryEncoder | ||
*/ | ||
function URLSearchParams(rawParams, queryEncoder) { | ||
@@ -90,13 +107,33 @@ if (rawParams === void 0) { rawParams = ''; } | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.clone = function () { | ||
var clone = new URLSearchParams('', this.queryEncoder); | ||
var /** @type {?} */ clone = new URLSearchParams('', this.queryEncoder); | ||
clone.appendAll(this); | ||
return clone; | ||
}; | ||
/** | ||
* @param {?} param | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.has = function (param) { return this.paramsMap.has(param); }; | ||
/** | ||
* @param {?} param | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.get = function (param) { | ||
var storedParam = this.paramsMap.get(param); | ||
var /** @type {?} */ storedParam = this.paramsMap.get(param); | ||
return Array.isArray(storedParam) ? storedParam[0] : null; | ||
}; | ||
/** | ||
* @param {?} param | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.getAll = function (param) { return this.paramsMap.get(param) || []; }; | ||
/** | ||
* @param {?} param | ||
* @param {?} val | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.set = function (param, val) { | ||
@@ -107,3 +144,3 @@ if (val === void 0 || val === null) { | ||
} | ||
var list = this.paramsMap.get(param) || []; | ||
var /** @type {?} */ list = this.paramsMap.get(param) || []; | ||
list.length = 0; | ||
@@ -113,12 +150,10 @@ list.push(val); | ||
}; | ||
// A merge operation | ||
// For each name-values pair in `searchParams`, perform `set(name, values[0])` | ||
// | ||
// E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4], c=[8], b=[7]" | ||
// | ||
// TODO(@caitp): document this better | ||
/** | ||
* @param {?} searchParams | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.setAll = function (searchParams) { | ||
var _this = this; | ||
searchParams.paramsMap.forEach(function (value, param) { | ||
var list = _this.paramsMap.get(param) || []; | ||
var /** @type {?} */ list = _this.paramsMap.get(param) || []; | ||
list.length = 0; | ||
@@ -129,21 +164,23 @@ list.push(value[0]); | ||
}; | ||
/** | ||
* @param {?} param | ||
* @param {?} val | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.append = function (param, val) { | ||
if (val === void 0 || val === null) | ||
return; | ||
var list = this.paramsMap.get(param) || []; | ||
var /** @type {?} */ list = this.paramsMap.get(param) || []; | ||
list.push(val); | ||
this.paramsMap.set(param, list); | ||
}; | ||
// A merge operation | ||
// For each name-values pair in `searchParams`, perform `append(name, value)` | ||
// for each value in `values`. | ||
// | ||
// E.g: "a=[1,2], c=[8]" + "a=[3,4], b=[7]" = "a=[1,2,3,4], c=[8], b=[7]" | ||
// | ||
// TODO(@caitp): document this better | ||
/** | ||
* @param {?} searchParams | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.appendAll = function (searchParams) { | ||
var _this = this; | ||
searchParams.paramsMap.forEach(function (value, param) { | ||
var list = _this.paramsMap.get(param) || []; | ||
for (var i = 0; i < value.length; ++i) { | ||
var /** @type {?} */ list = _this.paramsMap.get(param) || []; | ||
for (var /** @type {?} */ i = 0; i < value.length; ++i) { | ||
list.push(value[i]); | ||
@@ -154,15 +191,12 @@ } | ||
}; | ||
// A merge operation | ||
// For each name-values pair in `searchParams`, perform `delete(name)`, | ||
// followed by `set(name, values)` | ||
// | ||
// E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4,5,6], c=[8], b=[7]" | ||
// | ||
// TODO(@caitp): document this better | ||
/** | ||
* @param {?} searchParams | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.replaceAll = function (searchParams) { | ||
var _this = this; | ||
searchParams.paramsMap.forEach(function (value, param) { | ||
var list = _this.paramsMap.get(param) || []; | ||
var /** @type {?} */ list = _this.paramsMap.get(param) || []; | ||
list.length = 0; | ||
for (var i = 0; i < value.length; ++i) { | ||
for (var /** @type {?} */ i = 0; i < value.length; ++i) { | ||
list.push(value[i]); | ||
@@ -173,5 +207,8 @@ } | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.toString = function () { | ||
var _this = this; | ||
var paramsList = []; | ||
var /** @type {?} */ paramsList = []; | ||
this.paramsMap.forEach(function (values, k) { | ||
@@ -182,5 +219,17 @@ values.forEach(function (v) { return paramsList.push(_this.queryEncoder.encodeKey(k) + '=' + _this.queryEncoder.encodeValue(v)); }); | ||
}; | ||
/** | ||
* @param {?} param | ||
* @return {?} | ||
*/ | ||
URLSearchParams.prototype.delete = function (param) { this.paramsMap.delete(param); }; | ||
return URLSearchParams; | ||
}()); | ||
function URLSearchParams_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
URLSearchParams.prototype.paramsMap; | ||
/** @type {?} */ | ||
URLSearchParams.prototype.rawParams; | ||
/** @type {?} */ | ||
URLSearchParams.prototype.queryEncoder; | ||
} | ||
//# sourceMappingURL=url_search_params.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./mock_backend"}]} | ||
{"__symbolic":"module","version":2,"metadata":{},"exports":[{"from":"./mock_backend"}]} |
@@ -161,5 +161,5 @@ /** | ||
/** @nocollapse */ | ||
MockBackend.ctorParameters = []; | ||
MockBackend.ctorParameters = function () { return []; }; | ||
return MockBackend; | ||
}()); | ||
//# sourceMappingURL=mock_backend.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"MockBackend":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"verifyNoPendingRequests":[{"__symbolic":"method"}],"resolveAllConnections":[{"__symbolic":"method"}],"createConnection":[{"__symbolic":"method"}]}}}} | ||
{"__symbolic":"module","version":2,"metadata":{"MockConnection":{"__symbolic":"class"},"MockBackend":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"verifyNoPendingRequests":[{"__symbolic":"method"}],"resolveAllConnections":[{"__symbolic":"method"}],"createConnection":[{"__symbolic":"method"}]}}}} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
405462
86
6035