@angular/http
Advanced tools
Comparing version 2.0.0-rc.4 to 2.0.0-rc.5
@@ -1,2 +0,7 @@ | ||
var __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 __)};!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 isPresent(obj){return void 0!==obj&&null!==obj}function isBlank(obj){return void 0===obj||null===obj}function isString(obj){return"string"==typeof obj}function isArray(obj){return Array.isArray(obj)}function isJsObject(o){return null!==o&&("function"==typeof o||"object"==typeof o)}function getSymbolIterator(){if(isBlank(_symbolIterator))if(isPresent(globalScope.Symbol)&&isPresent(Symbol.iterator))_symbolIterator=Symbol.iterator;else for(var keys=Object.getOwnPropertyNames(Map.prototype),i=0;i<keys.length;++i){var key=keys[i];"entries"!==key&&"size"!==key&&Map.prototype[key]===Map.prototype.entries&&(_symbolIterator=key)}return _symbolIterator}function _getJsonpConnections(){return null===_jsonpConnections&&(_jsonpConnections=global$1[JSONP_HOME]={}),_jsonpConnections}function _flattenArray(source,target){if(isPresent(source))for(var i=0;i<source.length;i++){var item=source[i];isArray(item)?_flattenArray(item,target):target.push(item)}return target}function isListLikeIterable(obj){return!!isJsObject(obj)&&(isArray(obj)||!(obj instanceof Map$1)&&getSymbolIterator()in obj)}function iterateListLike(obj,fn){if(isArray(obj))for(var i=0;i<obj.length;i++)fn(obj[i]);else for(var item,iterator=obj[getSymbolIterator()]();!(item=iterator.next()).done;)fn(item.value)}function makeTypeError(message){return new TypeError(message)}function normalizeMethodName(method){if(isString(method)){var originalMethod=method;if(method=method.replace(/(\w)(\w*)/g,function(g0,g1,g2){return g1.toUpperCase()+g2.toLowerCase()}),method=exports.RequestMethod[method],"number"!=typeof method)throw makeTypeError('Invalid request method. The method "'+originalMethod+'" is not supported.')}return method}function getResponseURL(xhr){return"responseURL"in xhr?xhr.responseURL:/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())?xhr.getResponseHeader("X-Request-URL"):void 0}function paramParser(rawParams){void 0===rawParams&&(rawParams="");var map=new Map$1;if(rawParams.length>0){var params=rawParams.split("&");params.forEach(function(param){var split=param.split("=",2),key=split[0],val=split[1],list=isPresent(map.get(key))?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 httpRequest(backend,request){return backend.createConnection(request).response}function mergeOptions(defaultOpts,providedOpts,method,url){var newOptions=defaultOpts;return isPresent(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})):isPresent(method)?newOptions.merge(new RequestOptions({method:method,url:url})):newOptions.merge(new RequestOptions({url:url}))}function httpFactory(xhrBackend,requestOptions){return new Http(xhrBackend,requestOptions)}function jsonpFactory(jsonpBackend,requestOptions){return new Jsonp(jsonpBackend,requestOptions)}var globalScope;globalScope="undefined"==typeof window?"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:global:window;var global$1=globalScope;global$1.assert=function(condition){};var StringWrapper=function(){function StringWrapper(){}return StringWrapper.fromCharCode=function(code){return String.fromCharCode(code)},StringWrapper.charCodeAt=function(s,index){return s.charCodeAt(index)},StringWrapper.split=function(s,regExp){return s.split(regExp)},StringWrapper.equals=function(s,s2){return s===s2},StringWrapper.stripLeft=function(s,charVal){if(s&&s.length){for(var pos=0,i=0;i<s.length&&s[i]==charVal;i++)pos++;s=s.substring(pos)}return s},StringWrapper.stripRight=function(s,charVal){if(s&&s.length){for(var pos=s.length,i=s.length-1;i>=0&&s[i]==charVal;i--)pos--;s=s.substring(0,pos)}return s},StringWrapper.replace=function(s,from,replace){return s.replace(from,replace)},StringWrapper.replaceAll=function(s,from,replace){return s.replace(from,replace)},StringWrapper.slice=function(s,from,to){return void 0===from&&(from=0),void 0===to&&(to=null),s.slice(from,null===to?void 0:to)},StringWrapper.replaceAllMapped=function(s,from,cb){return s.replace(from,function(){for(var matches=[],_i=0;_i<arguments.length;_i++)matches[_i-0]=arguments[_i];return matches.splice(-2,2),cb(matches)})},StringWrapper.contains=function(s,substr){return s.indexOf(substr)!=-1},StringWrapper.compare=function(a,b){return a<b?-1:a>b?1:0},StringWrapper}(),Json=function(){function Json(){}return Json.parse=function(s){return global$1.JSON.parse(s)},Json.stringify=function(data){return global$1.JSON.stringify(data,null,2)},Json}(),_symbolIterator=null,_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}();BrowserJsonp.decorators=[{type:_angular_core.Injectable}];var BrowserXhr=function(){function BrowserXhr(){}return BrowserXhr.prototype.build=function(){return new XMLHttpRequest},BrowserXhr}();BrowserXhr.decorators=[{type:_angular_core.Injectable}],BrowserXhr.ctorParameters=[],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={}));var Map$1=global$1.Map,Set=global$1.Set,createMapFromPairs=function(){try{if(1===new Map$1([[1,2]]).size)return function(pairs){return new Map$1(pairs)}}catch(e){}return function(pairs){for(var map=new Map$1,i=0;i<pairs.length;i++){var pair=pairs[i];map.set(pair[0],pair[1])}return map}}(),createMapFromMap=function(){try{if(new Map$1(new Map$1))return function(m){return new Map$1(m)}}catch(e){}return function(m){var map=new Map$1;return m.forEach(function(v,k){map.set(k,v)}),map}}(),_clearValues=function(){return(new Map$1).keys().next?function(m){for(var k,keyIterator=m.keys();!(k=keyIterator.next()).done;)m.set(k.value,null)}:function(m){m.forEach(function(v,k){m.set(k,null)})}}(),_arrayFromMap=function(){try{if((new Map$1).values().next)return function(m,getValues){return getValues?Array.from(m.values()):Array.from(m.keys())}}catch(e){}return function(m,getValues){var res=ListWrapper.createFixedSize(m.size),i=0;return m.forEach(function(v,k){res[i]=getValues?v:k,i++}),res}}(),MapWrapper=function(){function MapWrapper(){}return MapWrapper.clone=function(m){return createMapFromMap(m)},MapWrapper.createFromStringMap=function(stringMap){var result=new Map$1;for(var prop in stringMap)result.set(prop,stringMap[prop]);return result},MapWrapper.toStringMap=function(m){var r={};return m.forEach(function(v,k){return r[k]=v}),r},MapWrapper.createFromPairs=function(pairs){return createMapFromPairs(pairs)},MapWrapper.clearValues=function(m){_clearValues(m)},MapWrapper.iterable=function(m){return m},MapWrapper.keys=function(m){return _arrayFromMap(m,!1)},MapWrapper.values=function(m){return _arrayFromMap(m,!0)},MapWrapper}(),StringMapWrapper=function(){function StringMapWrapper(){}return StringMapWrapper.create=function(){return{}},StringMapWrapper.contains=function(map,key){return map.hasOwnProperty(key)},StringMapWrapper.get=function(map,key){return map.hasOwnProperty(key)?map[key]:void 0},StringMapWrapper.set=function(map,key,value){map[key]=value},StringMapWrapper.keys=function(map){return Object.keys(map)},StringMapWrapper.values=function(map){return Object.keys(map).reduce(function(r,a){return r.push(map[a]),r},[])},StringMapWrapper.isEmpty=function(map){for(var prop in map)return!1;return!0},StringMapWrapper.delete=function(map,key){delete map[key]},StringMapWrapper.forEach=function(map,callback){for(var prop in map)map.hasOwnProperty(prop)&&callback(map[prop],prop)},StringMapWrapper.merge=function(m1,m2){var m={};for(var attr in m1)m1.hasOwnProperty(attr)&&(m[attr]=m1[attr]);for(var attr in m2)m2.hasOwnProperty(attr)&&(m[attr]=m2[attr]);return m},StringMapWrapper.equals=function(m1,m2){var k1=Object.keys(m1),k2=Object.keys(m2);if(k1.length!=k2.length)return!1;for(var key,i=0;i<k1.length;i++)if(key=k1[i],m1[key]!==m2[key])return!1;return!0},StringMapWrapper}(),ListWrapper=function(){function ListWrapper(){}return ListWrapper.createFixedSize=function(size){return new Array(size)},ListWrapper.createGrowableSize=function(size){return new Array(size)},ListWrapper.clone=function(array){return array.slice(0)},ListWrapper.forEachWithIndex=function(array,fn){for(var i=0;i<array.length;i++)fn(array[i],i)},ListWrapper.first=function(array){return array?array[0]:null},ListWrapper.last=function(array){return array&&0!=array.length?array[array.length-1]:null},ListWrapper.indexOf=function(array,value,startIndex){return void 0===startIndex&&(startIndex=0),array.indexOf(value,startIndex)},ListWrapper.contains=function(list,el){return list.indexOf(el)!==-1},ListWrapper.reversed=function(array){var a=ListWrapper.clone(array);return a.reverse()},ListWrapper.concat=function(a,b){return a.concat(b)},ListWrapper.insert=function(list,index,value){list.splice(index,0,value)},ListWrapper.removeAt=function(list,index){var res=list[index];return list.splice(index,1),res},ListWrapper.removeAll=function(list,items){for(var i=0;i<items.length;++i){var index=list.indexOf(items[i]);list.splice(index,1)}},ListWrapper.remove=function(list,el){var index=list.indexOf(el);return index>-1&&(list.splice(index,1),!0)},ListWrapper.clear=function(list){list.length=0},ListWrapper.isEmpty=function(list){return 0==list.length},ListWrapper.fill=function(list,value,start,end){void 0===start&&(start=0),void 0===end&&(end=null),list.fill(value,start,null===end?list.length:end)},ListWrapper.equals=function(a,b){if(a.length!=b.length)return!1;for(var i=0;i<a.length;++i)if(a[i]!==b[i])return!1;return!0},ListWrapper.slice=function(l,from,to){return void 0===from&&(from=0),void 0===to&&(to=null),l.slice(from,null===to?void 0:to)},ListWrapper.splice=function(l,from,length){return l.splice(from,length)},ListWrapper.sort=function(l,compareFn){isPresent(compareFn)?l.sort(compareFn):l.sort()},ListWrapper.toString=function(l){return l.toString()},ListWrapper.toJSON=function(l){return JSON.stringify(l)},ListWrapper.maximum=function(list,predicate){if(0==list.length)return null;for(var solution=null,maxValue=-(1/0),index=0;index<list.length;index++){var candidate=list[index];if(!isBlank(candidate)){var candidateValue=predicate(candidate);candidateValue>maxValue&&(solution=candidate,maxValue=candidateValue)}}return solution},ListWrapper.flatten=function(list){var target=[];return _flattenArray(list,target),target},ListWrapper.addAll=function(list,source){for(var i=0;i<source.length;i++)list.push(source[i])},ListWrapper}(),BaseException=(function(){var test=new Set([1,2,3]);return 3===test.size?function(lst){return new Set(lst)}:function(lst){var res=new Set(lst);if(res.size!==lst.length)for(var i=0;i<lst.length;i++)res.add(lst[i]);return res}}(),function(_super){function BaseException(message){void 0===message&&(message="--"),_super.call(this,message),this.message=message,this.stack=new Error(message).stack}return __extends(BaseException,_super),BaseException.prototype.toString=function(){return this.message},BaseException}(Error)),Headers=function(){function Headers(headers){var _this=this;return headers instanceof Headers?void(this._headersMap=headers._headersMap):(this._headersMap=new Map$1,void(isBlank(headers)||StringMapWrapper.forEach(headers,function(v,k){_this._headersMap.set(k,isListLikeIterable(v)?v:[v])})))}return Headers.fromResponseHeaderString=function(headersString){return headersString.trim().split("\n").map(function(val){return val.split(":")}).map(function(_a){var key=_a[0],parts=_a.slice(1);return[key.trim(),parts.join(":").trim()]}).reduce(function(headers,_a){var key=_a[0],value=_a[1];return!headers.set(key,value)&&headers},new Headers)},Headers.prototype.append=function(name,value){var mapName=this._headersMap.get(name),list=isListLikeIterable(mapName)?mapName:[];list.push(value),this._headersMap.set(name,list)},Headers.prototype.delete=function(name){this._headersMap.delete(name)},Headers.prototype.forEach=function(fn){this._headersMap.forEach(fn)},Headers.prototype.get=function(header){return ListWrapper.first(this._headersMap.get(header))},Headers.prototype.has=function(header){return this._headersMap.has(header)},Headers.prototype.keys=function(){return MapWrapper.keys(this._headersMap)},Headers.prototype.set=function(header,value){var list=[];if(isListLikeIterable(value)){var pushValue=value.join(",");list.push(pushValue)}else list.push(value);this._headersMap.set(header,list)},Headers.prototype.values=function(){return MapWrapper.values(this._headersMap)},Headers.prototype.toJSON=function(){var serializableHeaders={};return this._headersMap.forEach(function(values,name){var list=[];iterateListLike(values,function(val){return list=ListWrapper.concat(list,val.split(","))}),serializableHeaders[name]=list}),serializableHeaders},Headers.prototype.getAll=function(header){var headers=this._headersMap.get(header);return isListLikeIterable(headers)?headers:[]},Headers.prototype.entries=function(){throw new BaseException('"entries" method is not implemented on Headers class')},Headers}(),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=isPresent(body)?body:null,this.status=isPresent(status)?status:null,this.headers=isPresent(headers)?headers:null,this.statusText=isPresent(statusText)?statusText:null,this.type=isPresent(type)?type:null,this.url=isPresent(url)?url:null}return ResponseOptions.prototype.merge=function(options){return new ResponseOptions({body:isPresent(options)&&isPresent(options.body)?options.body:this.body,status:isPresent(options)&&isPresent(options.status)?options.status:this.status,headers:isPresent(options)&&isPresent(options.headers)?options.headers:this.headers,statusText:isPresent(options)&&isPresent(options.statusText)?options.statusText:this.statusText,type:isPresent(options)&&isPresent(options.type)?options.type:this.type,url:isPresent(options)&&isPresent(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(BaseResponseOptions,_super),BaseResponseOptions}(ResponseOptions);BaseResponseOptions.decorators=[{type:_angular_core.Injectable}],BaseResponseOptions.ctorParameters=[];var 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},Response=function(){function Response(responseOptions){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 Response.prototype.blob=function(){throw new BaseException('"blob()" method not implemented on Response superclass')},Response.prototype.json=function(){var jsonResponse;return isJsObject(this._body)?jsonResponse=this._body:isString(this._body)&&(jsonResponse=Json.parse(this._body)),jsonResponse},Response.prototype.text=function(){return this._body.toString()},Response.prototype.arrayBuffer=function(){throw new BaseException('"arrayBuffer()" method not implemented on Response superclass')},Response.prototype.toString=function(){return"Response with status: "+this.status+" "+this.statusText+" for URL: "+this.url},Response}(),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 makeTypeError(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=StringWrapper.replace(url,"=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 isPresent(baseResponseOptions)&&(responseOptions_1=baseResponseOptions.merge(responseOptions_1)),void responseObserver.error(new Response(responseOptions_1))}var responseOptions=new ResponseOptions({body:_this._responseData,url:url});isPresent(_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});isPresent(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),isPresent(script)&&_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_}(JSONPBackend);JSONPBackend_.decorators=[{type:_angular_core.Injectable}],JSONPBackend_.ctorParameters=[{type:BrowserJsonp},{type:ResponseOptions}];var 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),isPresent(req.withCredentials)&&(_xhr.withCredentials=req.withCredentials);var onLoad=function(){var body=isPresent(_xhr.response)?_xhr.response:_xhr.responseText;isString(body)&&(body=body.replace(XSSI_PREFIX,""));var headers=Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders()),url=getResponseURL(_xhr),status=1223===_xhr.status?204:_xhr.status;0===status&&(status=body?200:0);var statusText=_xhr.statusText||"OK",responseOptions=new ResponseOptions({body:body,status:status,headers:headers,statusText:statusText,url:url});isPresent(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});isPresent(baseResponseOptions)&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))};return _this.setDetectedContentType(req,_xhr),isPresent(req.headers)&&req.headers.forEach(function(values,name){return _xhr.setRequestHeader(name,values.join(","))}),_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(!isPresent(req.headers)||!isPresent(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.has(this._headerName)&&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}();XHRBackend.decorators=[{type:_angular_core.Injectable}],XHRBackend.ctorParameters=[{type:BrowserXhr},{type:ResponseOptions},{type:XSRFStrategy}];var 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;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 isListLikeIterable(storedParam)?ListWrapper.first(storedParam):null},URLSearchParams.prototype.getAll=function(param){var mapParam=this.paramsMap.get(param);return isPresent(mapParam)?mapParam:[]},URLSearchParams.prototype.set=function(param,val){var mapParam=this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list),list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.setAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list),list.push(value[0]),_this.paramsMap.set(param,list)})},URLSearchParams.prototype.append=function(param,val){var mapParam=this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.appendAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){for(var mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[],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 mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list);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}(),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;this.method=isPresent(method)?normalizeMethodName(method):null,this.headers=isPresent(headers)?headers:null,this.body=isPresent(body)?body:null,this.url=isPresent(url)?url:null,this.search=isPresent(search)?isString(search)?new URLSearchParams(search):search:null,this.withCredentials=isPresent(withCredentials)?withCredentials:null}return RequestOptions.prototype.merge=function(options){return new RequestOptions({method:isPresent(options)&&isPresent(options.method)?options.method:this.method,headers:isPresent(options)&&isPresent(options.headers)?options.headers:this.headers,body:isPresent(options)&&isPresent(options.body)?options.body:this.body,url:isPresent(options)&&isPresent(options.url)?options.url:this.url,search:isPresent(options)&&isPresent(options.search)?isString(options.search)?new URLSearchParams(options.search):options.search.clone():this.search,withCredentials:isPresent(options)&&isPresent(options.withCredentials)?options.withCredentials:this.withCredentials})},RequestOptions}(),BaseRequestOptions=function(_super){function BaseRequestOptions(){_super.call(this,{method:exports.RequestMethod.Get,headers:new Headers})}return __extends(BaseRequestOptions,_super),BaseRequestOptions}(RequestOptions);BaseRequestOptions.decorators=[{type:_angular_core.Injectable}],BaseRequestOptions.ctorParameters=[];var Request=function(){function Request(requestOptions){var url=requestOptions.url;if(this.url=requestOptions.url,isPresent(requestOptions.search)){var search=requestOptions.search.toString();if(search.length>0){var prefix="?";StringWrapper.contains(this.url,"?")&&(prefix="&"==this.url[this.url.length-1]?"":"&"),this.url=url+prefix+search}}this._body=requestOptions.body,this.contentType=this.detectContentType(),this.method=normalizeMethodName(requestOptions.method),this.headers=new Headers(requestOptions.headers),this.withCredentials=requestOptions.withCredentials}return Request.prototype.text=function(){return isPresent(this._body)?this._body.toString():""},Request.prototype.json=function(){return isPresent(this._body)?JSON.stringify(this._body):""},Request.prototype.arrayBuffer=function(){if(this._body instanceof ArrayBuffer)return this._body;throw"The request body isn't an array buffer"},Request.prototype.blob=function(){if(this._body instanceof Blob)return this._body;if(this._body instanceof ArrayBuffer)return new Blob([this._body]);throw"The request body isn't either a blob or an array buffer"},Request.prototype.detectContentType=function(){return null==this._body?ContentType.NONE:this._body instanceof URLSearchParams?ContentType.FORM:this._body instanceof FormData?ContentType.FORM_DATA:this._body instanceof Blob?ContentType.BLOB:this._body instanceof ArrayBuffer?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.json();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}(),noop$1=function(){},w="object"==typeof window?window:noop$1,FormData=w.FormData||noop$1,Blob=w.Blob||noop$1,ArrayBuffer=w.ArrayBuffer||noop$1,Http=function(){function Http(_backend,_defaultOptions){this._backend=_backend,this._defaultOptions=_defaultOptions}return Http.prototype.request=function(url,options){var responseObservable;if(isString(url))responseObservable=httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)));else{if(!(url instanceof Request))throw makeTypeError("First argument must be a url string or Request instance."); | ||
responseObservable=httpRequest(this._backend,url)}return responseObservable},Http.prototype.get=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)))},Http.prototype.post=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Post,url)))},Http.prototype.put=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Put,url)))},Http.prototype.delete=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Delete,url)))},Http.prototype.patch=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Patch,url)))},Http.prototype.head=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Head,url)))},Http}();Http.decorators=[{type:_angular_core.Injectable}],Http.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}];var Jsonp=function(_super){function Jsonp(backend,defaultOptions){_super.call(this,backend,defaultOptions)}return __extends(Jsonp,_super),Jsonp.prototype.request=function(url,options){var responseObservable;if(isString(url)&&(url=new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url))),!(url instanceof Request))throw makeTypeError("First argument must be a url string or Request instance.");return url.method!==exports.RequestMethod.Get&&makeTypeError("JSONP requests must use GET request method."),responseObservable=httpRequest(this._backend,url)},Jsonp}(Http);Jsonp.decorators=[{type:_angular_core.Injectable}],Jsonp.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}];var HTTP_PROVIDERS=[{provide:Http,useFactory:httpFactory,deps:[XHRBackend,RequestOptions]},BrowserXhr,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},XHRBackend,{provide:XSRFStrategy,useValue:new CookieXSRFStrategy}],HTTP_BINDINGS=HTTP_PROVIDERS,JSONP_PROVIDERS=[{provide:Jsonp,useFactory:jsonpFactory,deps:[JSONPBackend,RequestOptions]},BrowserJsonp,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},{provide:JSONPBackend,useClass:JSONPBackend_}],JSON_BINDINGS=JSONP_PROVIDERS;exports.HTTP_PROVIDERS=HTTP_PROVIDERS,exports.httpFactory=httpFactory,exports.HTTP_BINDINGS=HTTP_BINDINGS,exports.JSONP_PROVIDERS=JSONP_PROVIDERS,exports.JSON_BINDINGS=JSON_BINDINGS,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.Connection=Connection,exports.ConnectionBackend=ConnectionBackend,exports.XSRFStrategy=XSRFStrategy,exports.Request=Request,exports.Response=Response,exports.QueryEncoder=QueryEncoder,exports.URLSearchParams=URLSearchParams}); | ||
/** | ||
* @license Angular v2.0.0-rc.5 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
* License: MIT | ||
*/ | ||
var __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 __)};!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 isPresent(obj){return void 0!==obj&&null!==obj}function isBlank(obj){return void 0===obj||null===obj}function isString(obj){return"string"==typeof obj}function isArray(obj){return Array.isArray(obj)}function isJsObject(o){return null!==o&&("function"==typeof o||"object"==typeof o)}function getSymbolIterator(){if(isBlank(_symbolIterator))if(isPresent(globalScope.Symbol)&&isPresent(Symbol.iterator))_symbolIterator=Symbol.iterator;else for(var keys=Object.getOwnPropertyNames(Map.prototype),i=0;i<keys.length;++i){var key=keys[i];"entries"!==key&&"size"!==key&&Map.prototype[key]===Map.prototype.entries&&(_symbolIterator=key)}return _symbolIterator}function _getJsonpConnections(){return null===_jsonpConnections&&(_jsonpConnections=global$1[JSONP_HOME]={}),_jsonpConnections}function _flattenArray(source,target){if(isPresent(source))for(var i=0;i<source.length;i++){var item=source[i];isArray(item)?_flattenArray(item,target):target.push(item)}return target}function isListLikeIterable(obj){return!!isJsObject(obj)&&(isArray(obj)||!(obj instanceof Map$1)&&getSymbolIterator()in obj)}function iterateListLike(obj,fn){if(isArray(obj))for(var i=0;i<obj.length;i++)fn(obj[i]);else for(var item,iterator=obj[getSymbolIterator()]();!(item=iterator.next()).done;)fn(item.value)}function makeTypeError(message){return new TypeError(message)}function normalize(name){return name.toLowerCase()}function normalizeMethodName(method){if(isString(method)){var originalMethod=method;if(method=method.replace(/(\w)(\w*)/g,function(g0,g1,g2){return g1.toUpperCase()+g2.toLowerCase()}),method=exports.RequestMethod[method],"number"!=typeof method)throw makeTypeError('Invalid request method. The method "'+originalMethod+'" is not supported.')}return method}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}function paramParser(rawParams){void 0===rawParams&&(rawParams="");var map=new Map$1;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 httpRequest(backend,request){return backend.createConnection(request).response}function mergeOptions(defaultOpts,providedOpts,method,url){var newOptions=defaultOpts;return isPresent(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})):isPresent(method)?newOptions.merge(new RequestOptions({method:method,url:url})):newOptions.merge(new RequestOptions({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 globalScope;globalScope="undefined"==typeof window?"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:global:window;var global$1=globalScope;global$1.assert=function(condition){};var StringWrapper=function(){function StringWrapper(){}return StringWrapper.fromCharCode=function(code){return String.fromCharCode(code)},StringWrapper.charCodeAt=function(s,index){return s.charCodeAt(index)},StringWrapper.split=function(s,regExp){return s.split(regExp)},StringWrapper.equals=function(s,s2){return s===s2},StringWrapper.stripLeft=function(s,charVal){if(s&&s.length){for(var pos=0,i=0;i<s.length&&s[i]==charVal;i++)pos++;s=s.substring(pos)}return s},StringWrapper.stripRight=function(s,charVal){if(s&&s.length){for(var pos=s.length,i=s.length-1;i>=0&&s[i]==charVal;i--)pos--;s=s.substring(0,pos)}return s},StringWrapper.replace=function(s,from,replace){return s.replace(from,replace)},StringWrapper.replaceAll=function(s,from,replace){return s.replace(from,replace)},StringWrapper.slice=function(s,from,to){return void 0===from&&(from=0),void 0===to&&(to=null),s.slice(from,null===to?void 0:to)},StringWrapper.replaceAllMapped=function(s,from,cb){return s.replace(from,function(){for(var matches=[],_i=0;_i<arguments.length;_i++)matches[_i-0]=arguments[_i];return matches.splice(-2,2),cb(matches)})},StringWrapper.contains=function(s,substr){return s.indexOf(substr)!=-1},StringWrapper.compare=function(a,b){return a<b?-1:a>b?1:0},StringWrapper}(),Json=function(){function Json(){}return Json.parse=function(s){return global$1.JSON.parse(s)},Json.stringify=function(data){return global$1.JSON.stringify(data,null,2)},Json}(),_symbolIterator=null,_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}();BrowserJsonp.decorators=[{type:_angular_core.Injectable}];var BrowserXhr=function(){function BrowserXhr(){}return BrowserXhr.prototype.build=function(){return new XMLHttpRequest},BrowserXhr}();BrowserXhr.decorators=[{type:_angular_core.Injectable}],BrowserXhr.ctorParameters=[],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={}));var Map$1=global$1.Map,Set=global$1.Set,createMapFromPairs=function(){try{if(1===new Map$1([[1,2]]).size)return function(pairs){return new Map$1(pairs)}}catch(e){}return function(pairs){for(var map=new Map$1,i=0;i<pairs.length;i++){var pair=pairs[i];map.set(pair[0],pair[1])}return map}}(),createMapFromMap=function(){try{if(new Map$1(new Map$1))return function(m){return new Map$1(m)}}catch(e){}return function(m){var map=new Map$1;return m.forEach(function(v,k){map.set(k,v)}),map}}(),_clearValues=function(){return(new Map$1).keys().next?function(m){for(var k,keyIterator=m.keys();!(k=keyIterator.next()).done;)m.set(k.value,null)}:function(m){m.forEach(function(v,k){m.set(k,null)})}}(),_arrayFromMap=function(){try{if((new Map$1).values().next)return function(m,getValues){return getValues?Array.from(m.values()):Array.from(m.keys())}}catch(e){}return function(m,getValues){var res=ListWrapper.createFixedSize(m.size),i=0;return m.forEach(function(v,k){res[i]=getValues?v:k,i++}),res}}(),MapWrapper=function(){function MapWrapper(){}return MapWrapper.clone=function(m){return createMapFromMap(m)},MapWrapper.createFromStringMap=function(stringMap){var result=new Map$1;for(var prop in stringMap)result.set(prop,stringMap[prop]);return result},MapWrapper.toStringMap=function(m){var r={};return m.forEach(function(v,k){return r[k]=v}),r},MapWrapper.createFromPairs=function(pairs){return createMapFromPairs(pairs)},MapWrapper.clearValues=function(m){_clearValues(m)},MapWrapper.iterable=function(m){return m},MapWrapper.keys=function(m){return _arrayFromMap(m,!1)},MapWrapper.values=function(m){return _arrayFromMap(m,!0)},MapWrapper}(),StringMapWrapper=function(){function StringMapWrapper(){}return StringMapWrapper.create=function(){return{}},StringMapWrapper.contains=function(map,key){return map.hasOwnProperty(key)},StringMapWrapper.get=function(map,key){return map.hasOwnProperty(key)?map[key]:void 0},StringMapWrapper.set=function(map,key,value){map[key]=value},StringMapWrapper.keys=function(map){return Object.keys(map)},StringMapWrapper.values=function(map){return Object.keys(map).map(function(k){return map[k]})},StringMapWrapper.isEmpty=function(map){for(var prop in map)return!1;return!0},StringMapWrapper.delete=function(map,key){delete map[key]},StringMapWrapper.forEach=function(map,callback){for(var _i=0,_a=Object.keys(map);_i<_a.length;_i++){var k=_a[_i];callback(map[k],k)}},StringMapWrapper.merge=function(m1,m2){for(var m={},_i=0,_a=Object.keys(m1);_i<_a.length;_i++){var k=_a[_i];m[k]=m1[k]}for(var _b=0,_c=Object.keys(m2);_b<_c.length;_b++){var k=_c[_b];m[k]=m2[k]}return m},StringMapWrapper.equals=function(m1,m2){var k1=Object.keys(m1),k2=Object.keys(m2);if(k1.length!=k2.length)return!1;for(var key,i=0;i<k1.length;i++)if(key=k1[i],m1[key]!==m2[key])return!1;return!0},StringMapWrapper}(),ListWrapper=function(){function ListWrapper(){}return ListWrapper.createFixedSize=function(size){return new Array(size)},ListWrapper.createGrowableSize=function(size){return new Array(size)},ListWrapper.clone=function(array){return array.slice(0)},ListWrapper.forEachWithIndex=function(array,fn){for(var i=0;i<array.length;i++)fn(array[i],i)},ListWrapper.first=function(array){return array?array[0]:null},ListWrapper.last=function(array){return array&&0!=array.length?array[array.length-1]:null},ListWrapper.indexOf=function(array,value,startIndex){return void 0===startIndex&&(startIndex=0),array.indexOf(value,startIndex)},ListWrapper.contains=function(list,el){return list.indexOf(el)!==-1},ListWrapper.reversed=function(array){var a=ListWrapper.clone(array);return a.reverse()},ListWrapper.concat=function(a,b){return a.concat(b)},ListWrapper.insert=function(list,index,value){list.splice(index,0,value)},ListWrapper.removeAt=function(list,index){var res=list[index];return list.splice(index,1),res},ListWrapper.removeAll=function(list,items){for(var i=0;i<items.length;++i){var index=list.indexOf(items[i]);list.splice(index,1)}},ListWrapper.remove=function(list,el){var index=list.indexOf(el);return index>-1&&(list.splice(index,1),!0)},ListWrapper.clear=function(list){list.length=0},ListWrapper.isEmpty=function(list){return 0==list.length},ListWrapper.fill=function(list,value,start,end){void 0===start&&(start=0),void 0===end&&(end=null),list.fill(value,start,null===end?list.length:end)},ListWrapper.equals=function(a,b){if(a.length!=b.length)return!1;for(var i=0;i<a.length;++i)if(a[i]!==b[i])return!1;return!0},ListWrapper.slice=function(l,from,to){return void 0===from&&(from=0),void 0===to&&(to=null),l.slice(from,null===to?void 0:to)},ListWrapper.splice=function(l,from,length){return l.splice(from,length)},ListWrapper.sort=function(l,compareFn){isPresent(compareFn)?l.sort(compareFn):l.sort()},ListWrapper.toString=function(l){return l.toString()},ListWrapper.toJSON=function(l){return JSON.stringify(l)},ListWrapper.maximum=function(list,predicate){if(0==list.length)return null;for(var solution=null,maxValue=-(1/0),index=0;index<list.length;index++){var candidate=list[index];if(!isBlank(candidate)){var candidateValue=predicate(candidate);candidateValue>maxValue&&(solution=candidate,maxValue=candidateValue)}}return solution},ListWrapper.flatten=function(list){var target=[];return _flattenArray(list,target),target},ListWrapper.addAll=function(list,source){for(var i=0;i<source.length;i++)list.push(source[i])},ListWrapper}(),BaseException=(function(){var test=new Set([1,2,3]);return 3===test.size?function(lst){return new Set(lst)}:function(lst){var res=new Set(lst);if(res.size!==lst.length)for(var i=0;i<lst.length;i++)res.add(lst[i]);return res}}(),function(_super){function BaseException(message){void 0===message&&(message="--"),_super.call(this,message),this.message=message,this.stack=new Error(message).stack}return __extends(BaseException,_super),BaseException.prototype.toString=function(){return this.message},BaseException}(Error)),Headers=function(){function Headers(headers){var _this=this;return headers instanceof Headers?void(this._headersMap=headers._headersMap):(this._headersMap=new Map$1,void(isBlank(headers)||StringMapWrapper.forEach(headers,function(v,k){_this._headersMap.set(normalize(k),isListLikeIterable(v)?v:[v])})))}return Headers.fromResponseHeaderString=function(headersString){var headers=new Headers;return headersString.split("\n").forEach(function(line){var index=line.indexOf(":");if(index>0){var key=line.substring(0,index),value=line.substring(index+1).trim();headers.set(key,value)}}),headers},Headers.prototype.append=function(name,value){name=normalize(name);var mapName=this._headersMap.get(name),list=isListLikeIterable(mapName)?mapName:[];list.push(value),this._headersMap.set(name,list)},Headers.prototype.delete=function(name){this._headersMap.delete(normalize(name))},Headers.prototype.forEach=function(fn){this._headersMap.forEach(fn)},Headers.prototype.get=function(header){return ListWrapper.first(this._headersMap.get(normalize(header)))},Headers.prototype.has=function(header){return this._headersMap.has(normalize(header))},Headers.prototype.keys=function(){return MapWrapper.keys(this._headersMap)},Headers.prototype.set=function(header,value){var list=[];if(isListLikeIterable(value)){var pushValue=value.join(",");list.push(pushValue)}else list.push(value);this._headersMap.set(normalize(header),list)},Headers.prototype.values=function(){return MapWrapper.values(this._headersMap)},Headers.prototype.toJSON=function(){var serializableHeaders={};return this._headersMap.forEach(function(values,name){var list=[];iterateListLike(values,function(val){return list=ListWrapper.concat(list,val.split(","))}),serializableHeaders[normalize(name)]=list}),serializableHeaders},Headers.prototype.getAll=function(header){var headers=this._headersMap.get(normalize(header));return isListLikeIterable(headers)?headers:[]},Headers.prototype.entries=function(){throw new BaseException('"entries" method is not implemented on Headers class')},Headers}(),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=isPresent(body)?body:null,this.status=isPresent(status)?status:null,this.headers=isPresent(headers)?headers:null,this.statusText=isPresent(statusText)?statusText:null,this.type=isPresent(type)?type:null,this.url=isPresent(url)?url:null}return ResponseOptions.prototype.merge=function(options){return new ResponseOptions({body:isPresent(options)&&isPresent(options.body)?options.body:this.body,status:isPresent(options)&&isPresent(options.status)?options.status:this.status,headers:isPresent(options)&&isPresent(options.headers)?options.headers:this.headers,statusText:isPresent(options)&&isPresent(options.statusText)?options.statusText:this.statusText,type:isPresent(options)&&isPresent(options.type)?options.type:this.type,url:isPresent(options)&&isPresent(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(BaseResponseOptions,_super),BaseResponseOptions}(ResponseOptions);BaseResponseOptions.decorators=[{type:_angular_core.Injectable}],BaseResponseOptions.ctorParameters=[];var 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 isListLikeIterable(storedParam)?ListWrapper.first(storedParam):null},URLSearchParams.prototype.getAll=function(param){var mapParam=this.paramsMap.get(param);return isPresent(mapParam)?mapParam:[]},URLSearchParams.prototype.set=function(param,val){var mapParam=this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list),list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.setAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){var mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list),list.push(value[0]),_this.paramsMap.set(param,list)})},URLSearchParams.prototype.append=function(param,val){var mapParam=this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];list.push(val),this.paramsMap.set(param,list)},URLSearchParams.prototype.appendAll=function(searchParams){var _this=this;searchParams.paramsMap.forEach(function(value,param){for(var mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[],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 mapParam=_this.paramsMap.get(param),list=isPresent(mapParam)?mapParam:[];ListWrapper.clear(list);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 isString(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)):isJsObject(this._body)?Json.stringify(this._body):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}(),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(Response,_super),Response.prototype.toString=function(){return"Response with status: "+this.status+" "+this.statusText+" for URL: "+this.url},Response}(Body),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 makeTypeError(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=StringWrapper.replace(url,"=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 isPresent(baseResponseOptions)&&(responseOptions_1=baseResponseOptions.merge(responseOptions_1)),void responseObserver.error(new Response(responseOptions_1))}var responseOptions=new ResponseOptions({body:_this._responseData,url:url});isPresent(_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});isPresent(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),isPresent(script)&&_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_}(JSONPBackend);JSONPBackend_.decorators=[{type:_angular_core.Injectable}],JSONPBackend_.ctorParameters=[{type:BrowserJsonp},{type:ResponseOptions}];var 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),isPresent(req.withCredentials)&&(_xhr.withCredentials=req.withCredentials);var onLoad=function(){var body=isPresent(_xhr.response)?_xhr.response:_xhr.responseText;isString(body)&&(body=body.replace(XSSI_PREFIX,""));var headers=Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders()),url=getResponseURL(_xhr),status=1223===_xhr.status?204:_xhr.status;0===status&&(status=body?200:0);var statusText=_xhr.statusText||"OK",responseOptions=new ResponseOptions({body:body,status:status,headers:headers,statusText:statusText,url:url});isPresent(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});isPresent(baseResponseOptions)&&(responseOptions=baseResponseOptions.merge(responseOptions)),responseObserver.error(new Response(responseOptions))};if(_this.setDetectedContentType(req,_xhr),isPresent(req.headers)&&req.headers.forEach(function(values,name){return _xhr.setRequestHeader(name,values.join(","))}),isPresent(req.responseType)&&isPresent(_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(!isPresent(req.headers)||!isPresent(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.has(this._headerName)&&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}();XHRBackend.decorators=[{type:_angular_core.Injectable}],XHRBackend.ctorParameters=[{type:BrowserXhr},{type:ResponseOptions},{type:XSRFStrategy}];var 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=isPresent(method)?normalizeMethodName(method):null,this.headers=isPresent(headers)?headers:null,this.body=isPresent(body)?body:null,this.url=isPresent(url)?url:null,this.search=isPresent(search)?isString(search)?new URLSearchParams(search):search:null,this.withCredentials=isPresent(withCredentials)?withCredentials:null,this.responseType=isPresent(responseType)?responseType:null}return RequestOptions.prototype.merge=function(options){return new RequestOptions({method:isPresent(options)&&isPresent(options.method)?options.method:this.method,headers:isPresent(options)&&isPresent(options.headers)?options.headers:this.headers,body:isPresent(options)&&isPresent(options.body)?options.body:this.body,url:isPresent(options)&&isPresent(options.url)?options.url:this.url,search:isPresent(options)&&isPresent(options.search)?isString(options.search)?new URLSearchParams(options.search):options.search.clone():this.search,withCredentials:isPresent(options)&&isPresent(options.withCredentials)?options.withCredentials:this.withCredentials,responseType:isPresent(options)&&isPresent(options.responseType)?options.responseType:this.responseType})},RequestOptions}(),BaseRequestOptions=function(_super){function BaseRequestOptions(){_super.call(this,{method:exports.RequestMethod.Get,headers:new Headers})}return __extends(BaseRequestOptions,_super),BaseRequestOptions}(RequestOptions);BaseRequestOptions.decorators=[{type:_angular_core.Injectable}],BaseRequestOptions.ctorParameters=[];var Request=function(_super){function Request(requestOptions){_super.call(this);var url=requestOptions.url;if(this.url=requestOptions.url,isPresent(requestOptions.search)){var search=requestOptions.search.toString();if(search.length>0){var prefix="?";StringWrapper.contains(this.url,"?")&&(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(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$1=function(){},w="object"==typeof window?window:noop$1,FormData=w.FormData||noop$1,Blob$1=w.Blob||noop$1,ArrayBuffer$1=w.ArrayBuffer||noop$1,Http=function(){function Http(_backend,_defaultOptions){this._backend=_backend,this._defaultOptions=_defaultOptions}return Http.prototype.request=function(url,options){var responseObservable;if(isString(url))responseObservable=httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)));else{if(!(url instanceof Request))throw makeTypeError("First argument must be a url string or Request instance.");responseObservable=httpRequest(this._backend,url)}return responseObservable},Http.prototype.get=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url)))},Http.prototype.post=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Post,url)))},Http.prototype.put=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Put,url)))},Http.prototype.delete=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Delete,url)))},Http.prototype.patch=function(url,body,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body:body})),options,exports.RequestMethod.Patch,url)))},Http.prototype.head=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Head,url)))},Http.prototype.options=function(url,options){return httpRequest(this._backend,new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Options,url)))},Http}();Http.decorators=[{type:_angular_core.Injectable}],Http.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}];var Jsonp=function(_super){function Jsonp(backend,defaultOptions){_super.call(this,backend,defaultOptions)}return __extends(Jsonp,_super),Jsonp.prototype.request=function(url,options){var responseObservable;if(isString(url)&&(url=new Request(mergeOptions(this._defaultOptions,options,exports.RequestMethod.Get,url))),!(url instanceof Request))throw makeTypeError("First argument must be a url string or Request instance.");return url.method!==exports.RequestMethod.Get&&makeTypeError("JSONP requests must use GET request method."),responseObservable=httpRequest(this._backend,url)},Jsonp}(Http);Jsonp.decorators=[{type:_angular_core.Injectable}],Jsonp.ctorParameters=[{type:ConnectionBackend},{type:RequestOptions}];var HTTP_PROVIDERS=[{provide:Http,useFactory:httpFactory,deps:[XHRBackend,RequestOptions]},BrowserXhr,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},XHRBackend,{provide:XSRFStrategy,useFactory:_createDefaultCookieXSRFStrategy}],HTTP_BINDINGS=HTTP_PROVIDERS,JSONP_PROVIDERS=[{provide:Jsonp,useFactory:jsonpFactory,deps:[JSONPBackend,RequestOptions]},BrowserJsonp,{provide:RequestOptions,useClass:BaseRequestOptions},{provide:ResponseOptions,useClass:BaseResponseOptions},{provide:JSONPBackend,useClass:JSONPBackend_}],JSON_BINDINGS=JSONP_PROVIDERS,HttpModule=function(){function HttpModule(){}return HttpModule}();HttpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:HTTP_PROVIDERS}]}];var JsonpModule=function(){function JsonpModule(){}return JsonpModule}();JsonpModule.decorators=[{type:_angular_core.NgModule,args:[{providers:JSONP_PROVIDERS}]}],exports.HTTP_PROVIDERS=HTTP_PROVIDERS,exports._createDefaultCookieXSRFStrategy=_createDefaultCookieXSRFStrategy,exports.httpFactory=httpFactory,exports.HTTP_BINDINGS=HTTP_BINDINGS,exports.JSONP_PROVIDERS=JSONP_PROVIDERS,exports.JSON_BINDINGS=JSON_BINDINGS,exports.HttpModule=HttpModule,exports.JsonpModule=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.Connection=Connection,exports.ConnectionBackend=ConnectionBackend,exports.XSRFStrategy=XSRFStrategy,exports.Request=Request,exports.Response=Response,exports.QueryEncoder=QueryEncoder,exports.URLSearchParams=URLSearchParams}); |
@@ -1,2 +0,2 @@ | ||
import { XHRBackend } from './src/backends/xhr_backend'; | ||
import { CookieXSRFStrategy, XHRBackend } from './src/backends/xhr_backend'; | ||
import { RequestOptions } from './src/base_request_options'; | ||
@@ -9,3 +9,3 @@ import { Http } from './src/http'; | ||
export { BaseResponseOptions, ResponseOptions } from './src/base_response_options'; | ||
export { ReadyState, RequestMethod, ResponseType } from './src/enums'; | ||
export { ReadyState, RequestMethod, ResponseContentType, ResponseType } from './src/enums'; | ||
export { Headers } from './src/headers'; | ||
@@ -160,3 +160,3 @@ export { Http, Jsonp } from './src/http'; | ||
* | ||
* @experimental | ||
* @deprecated | ||
*/ | ||
@@ -167,2 +167,6 @@ export declare const HTTP_PROVIDERS: any[]; | ||
*/ | ||
export declare function _createDefaultCookieXSRFStrategy(): CookieXSRFStrategy; | ||
/** | ||
* @experimental | ||
*/ | ||
export declare function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http; | ||
@@ -291,1 +295,15 @@ /** | ||
export declare const JSON_BINDINGS: any[]; | ||
/** | ||
* The module that includes http's providers | ||
* | ||
* @experimental | ||
*/ | ||
export declare class HttpModule { | ||
} | ||
/** | ||
* The module that includes jsonp's providers | ||
* | ||
* @experimental | ||
*/ | ||
export declare class JsonpModule { | ||
} |
@@ -8,2 +8,3 @@ /** | ||
*/ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserJsonp } from './src/backends/browser_jsonp'; | ||
@@ -22,3 +23,3 @@ import { BrowserXhr } from './src/backends/browser_xhr'; | ||
export { BaseResponseOptions, ResponseOptions } from './src/base_response_options'; | ||
export { ReadyState, RequestMethod, ResponseType } from './src/enums'; | ||
export { ReadyState, RequestMethod, ResponseContentType, ResponseType } from './src/enums'; | ||
export { Headers } from './src/headers'; | ||
@@ -173,3 +174,3 @@ export { Http, Jsonp } from './src/http'; | ||
* | ||
* @experimental | ||
* @deprecated | ||
*/ | ||
@@ -184,3 +185,3 @@ export const HTTP_PROVIDERS = [ | ||
XHRBackend, | ||
{ provide: XSRFStrategy, useValue: new CookieXSRFStrategy() }, | ||
{ provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy }, | ||
]; | ||
@@ -190,2 +191,8 @@ /** | ||
*/ | ||
export function _createDefaultCookieXSRFStrategy() { | ||
return new CookieXSRFStrategy(); | ||
} | ||
/** | ||
* @experimental | ||
*/ | ||
export function httpFactory(xhrBackend, requestOptions) { | ||
@@ -327,2 +334,14 @@ return new Http(xhrBackend, requestOptions); | ||
export const JSON_BINDINGS = JSONP_PROVIDERS; | ||
export class HttpModule { | ||
} | ||
/** @nocollapse */ | ||
HttpModule.decorators = [ | ||
{ type: NgModule, args: [{ providers: HTTP_PROVIDERS },] }, | ||
]; | ||
export class JsonpModule { | ||
} | ||
/** @nocollapse */ | ||
JsonpModule.decorators = [ | ||
{ type: NgModule, args: [{ providers: JSONP_PROVIDERS },] }, | ||
]; | ||
//# sourceMappingURL=http.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"HTTP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./src/interfaces","name":"XSRFStrategy"},"useValue":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"CookieXSRFStrategy"}}}],"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HTTP_BINDINGS":{"__symbolic":"reference","name":"HTTP_PROVIDERS"},"JSONP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend_"}}],"JSON_BINDINGS":{"__symbolic":"reference","name":"JSONP_PROVIDERS"}}} | ||
{"__symbolic":"module","version":1,"metadata":{"HTTP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./src/interfaces","name":"XSRFStrategy"},"useFactory":{"__symbolic":"reference","name":"_createDefaultCookieXSRFStrategy"}}],"_createDefaultCookieXSRFStrategy":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"CookieXSRFStrategy"}}},"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HTTP_BINDINGS":{"__symbolic":"reference","name":"HTTP_PROVIDERS"},"JSONP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend_"}}],"JSON_BINDINGS":{"__symbolic":"reference","name":"JSONP_PROVIDERS"},"HttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":{"__symbolic":"reference","name":"HTTP_PROVIDERS"}}]}]},"JsonpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":{"__symbolic":"reference","name":"JSONP_PROVIDERS"}}]}]}},"exports":[{"from":"./src/backends/browser_xhr","export":["BrowserXhr"]},{"from":"./src/backends/jsonp_backend","export":["JSONPBackend","JSONPConnection"]},{"from":"./src/backends/xhr_backend","export":["CookieXSRFStrategy","XHRBackend","XHRConnection"]},{"from":"./src/base_request_options","export":["BaseRequestOptions","RequestOptions"]},{"from":"./src/base_response_options","export":["BaseResponseOptions","ResponseOptions"]},{"from":"./src/enums","export":["ReadyState","RequestMethod","ResponseContentType","ResponseType"]},{"from":"./src/headers","export":["Headers"]},{"from":"./src/http","export":["Http","Jsonp"]},{"from":"./src/interfaces","export":["Connection","ConnectionBackend","RequestOptionsArgs","ResponseOptionsArgs","XSRFStrategy"]},{"from":"./src/static_request","export":["Request"]},{"from":"./src/static_response","export":["Response"]},{"from":"./src/url_search_params","export":["QueryEncoder","URLSearchParams"]}]} |
@@ -31,4 +31,4 @@ import { Observable } from 'rxjs/Observable'; | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) for more | ||
* information on XSRF. | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* | ||
@@ -35,0 +35,0 @@ * Applications can configure custom cookie and header names by binding an instance of this class |
@@ -12,3 +12,3 @@ /** | ||
import { ResponseOptions } from '../base_response_options'; | ||
import { ContentType, RequestMethod, ResponseType } from '../enums'; | ||
import { ContentType, RequestMethod, ResponseContentType, ResponseType } from '../enums'; | ||
import { isPresent, isString } from '../facade/lang'; | ||
@@ -91,2 +91,21 @@ import { Headers } from '../headers'; | ||
} | ||
// Select the correct buffer type to store the response | ||
if (isPresent(req.responseType) && isPresent(_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'); | ||
} | ||
} | ||
_xhr.addEventListener('load', onLoad); | ||
@@ -112,9 +131,9 @@ _xhr.addEventListener('error', onError); | ||
case ContentType.JSON: | ||
_xhr.setRequestHeader('Content-Type', 'application/json'); | ||
_xhr.setRequestHeader('content-type', 'application/json'); | ||
break; | ||
case ContentType.FORM: | ||
_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
_xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
break; | ||
case ContentType.TEXT: | ||
_xhr.setRequestHeader('Content-Type', 'text/plain'); | ||
_xhr.setRequestHeader('content-type', 'text/plain'); | ||
break; | ||
@@ -124,3 +143,3 @@ case ContentType.BLOB: | ||
if (blob.type) { | ||
_xhr.setRequestHeader('Content-Type', blob.type); | ||
_xhr.setRequestHeader('content-type', blob.type); | ||
} | ||
@@ -133,4 +152,4 @@ break; | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) for more | ||
* information on XSRF. | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* | ||
@@ -137,0 +156,0 @@ * Applications can configure custom cookie and header names by binding an instance of this class |
@@ -1,2 +0,2 @@ | ||
import { RequestMethod } from './enums'; | ||
import { RequestMethod, ResponseContentType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -57,3 +57,4 @@ import { RequestOptionsArgs } from './interfaces'; | ||
withCredentials: boolean; | ||
constructor({method, headers, body, url, search, withCredentials}?: RequestOptionsArgs); | ||
responseType: ResponseContentType; | ||
constructor({method, headers, body, url, search, withCredentials, responseType}?: RequestOptionsArgs); | ||
/** | ||
@@ -60,0 +61,0 @@ * Creates a copy of the `RequestOptions` instance, using the optional input as values to override |
@@ -41,3 +41,3 @@ /** | ||
export class RequestOptions { | ||
constructor({ method, headers, body, url, search, withCredentials } = {}) { | ||
constructor({ method, headers, body, url, search, withCredentials, responseType } = {}) { | ||
this.method = isPresent(method) ? normalizeMethodName(method) : null; | ||
@@ -51,2 +51,3 @@ this.headers = isPresent(headers) ? headers : null; | ||
this.withCredentials = isPresent(withCredentials) ? withCredentials : null; | ||
this.responseType = isPresent(responseType) ? responseType : null; | ||
} | ||
@@ -90,3 +91,5 @@ /** | ||
options.withCredentials : | ||
this.withCredentials | ||
this.withCredentials, | ||
responseType: isPresent(options) && isPresent(options.responseType) ? options.responseType : | ||
this.responseType | ||
}); | ||
@@ -93,0 +96,0 @@ } |
@@ -33,5 +33,5 @@ import { Headers } from './headers'; | ||
/** | ||
* String or Object representing the body of the {@link Response}. | ||
* String, Object, ArrayBuffer or Blob representing the body of the {@link Response}. | ||
*/ | ||
body: string | Object; | ||
body: string | Object | ArrayBuffer | Blob; | ||
/** | ||
@@ -38,0 +38,0 @@ * Http {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html status code} |
@@ -60,1 +60,11 @@ /** | ||
} | ||
/** | ||
* Define which buffer to use to store the response | ||
* @experimental | ||
*/ | ||
export declare enum ResponseContentType { | ||
Text = 0, | ||
Json = 1, | ||
ArrayBuffer = 2, | ||
Blob = 3, | ||
} |
@@ -64,2 +64,13 @@ /** | ||
})(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 = {})); | ||
//# sourceMappingURL=enums.js.map |
@@ -47,3 +47,3 @@ export declare var Map: MapConstructor; | ||
[key: string]: V; | ||
}, callback: Function): void; | ||
}, callback: (v: V, K: string) => void): void; | ||
static merge<V>(m1: { | ||
@@ -50,0 +50,0 @@ [key: string]: V; |
@@ -120,6 +120,3 @@ /** | ||
static values(map) { | ||
return Object.keys(map).reduce((r, a) => { | ||
r.push(map[a]); | ||
return r; | ||
}, []); | ||
return Object.keys(map).map((k) => map[k]); | ||
} | ||
@@ -134,6 +131,4 @@ static isEmpty(map) { | ||
static forEach(map, callback) { | ||
for (var prop in map) { | ||
if (map.hasOwnProperty(prop)) { | ||
callback(map[prop], prop); | ||
} | ||
for (let k of Object.keys(map)) { | ||
callback(map[k], k); | ||
} | ||
@@ -143,11 +138,7 @@ } | ||
var m = {}; | ||
for (var attr in m1) { | ||
if (m1.hasOwnProperty(attr)) { | ||
m[attr] = m1[attr]; | ||
} | ||
for (let k of Object.keys(m1)) { | ||
m[k] = m1[k]; | ||
} | ||
for (var attr in m2) { | ||
if (m2.hasOwnProperty(attr)) { | ||
m[attr] = m2[attr]; | ||
} | ||
for (let k of Object.keys(m2)) { | ||
m[k] = m2[k]; | ||
} | ||
@@ -154,0 +145,0 @@ return m; |
@@ -18,3 +18,3 @@ /** | ||
* | ||
* bootstrap(MyApp, {provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* bootstrap(MyApp, [{provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* | ||
@@ -21,0 +21,0 @@ * ``` |
@@ -38,3 +38,3 @@ /** | ||
* | ||
* bootstrap(MyApp, {provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* bootstrap(MyApp, [{provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* | ||
@@ -41,0 +41,0 @@ * ``` |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"makeTypeError":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"TypeError"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"makeTypeError":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"TypeError"},"arguments":[{"__symbolic":"reference","name":"message"}]}}},"exports":[{"from":"./exception_handler","export":["ExceptionHandler"]}]} |
@@ -30,3 +30,2 @@ /** | ||
export declare function scheduleMicroTask(fn: Function): void; | ||
export declare const IS_DART: boolean; | ||
declare var _global: BrowserNodeGlobal; | ||
@@ -109,18 +108,2 @@ export { _global as global }; | ||
export declare var RegExp: RegExpConstructor; | ||
export declare class RegExpWrapper { | ||
static create(regExpStr: string, flags?: string): RegExp; | ||
static firstMatch(regExp: RegExp, input: string): RegExpExecArray; | ||
static test(regExp: RegExp, input: string): boolean; | ||
static matcher(regExp: RegExp, input: string): { | ||
re: RegExp; | ||
input: string; | ||
}; | ||
static replaceAll(regExp: RegExp, input: string, replace: Function): string; | ||
} | ||
export declare class RegExpMatcherWrapper { | ||
static next(matcher: { | ||
re: RegExp; | ||
input: string; | ||
}): RegExpExecArray; | ||
} | ||
export declare class FunctionWrapper { | ||
@@ -127,0 +110,0 @@ static apply(fn: Function, posArgs: any): any; |
@@ -24,3 +24,2 @@ /** | ||
} | ||
export const IS_DART = false; | ||
// Need to declare a new variable for global here since TypeScript | ||
@@ -82,3 +81,5 @@ // exports the original value of the symbol. | ||
export function isPromise(obj) { | ||
return obj instanceof _global.Promise; | ||
// allow any Promise/A+ compliant thenable. | ||
// It's up to the caller to ensure that obj.then conforms to the spec | ||
return isPresent(obj) && isFunction(obj.then); | ||
} | ||
@@ -99,8 +100,8 @@ export function isArray(obj) { | ||
} | ||
if (token.overriddenName) { | ||
return token.overriddenName; | ||
} | ||
if (token.name) { | ||
return token.name; | ||
} | ||
if (token.overriddenName) { | ||
return token.overriddenName; | ||
} | ||
var res = token.toString(); | ||
@@ -231,44 +232,2 @@ var newLineIndex = res.indexOf('\n'); | ||
export var RegExp = _global.RegExp; | ||
export class RegExpWrapper { | ||
static create(regExpStr, flags = '') { | ||
flags = flags.replace(/g/g, ''); | ||
return new _global.RegExp(regExpStr, flags + 'g'); | ||
} | ||
static firstMatch(regExp, input) { | ||
// Reset multimatch regex state | ||
regExp.lastIndex = 0; | ||
return regExp.exec(input); | ||
} | ||
static test(regExp, input) { | ||
regExp.lastIndex = 0; | ||
return regExp.test(input); | ||
} | ||
static matcher(regExp, input) { | ||
// Reset regex state for the case | ||
// someone did not loop over all matches | ||
// last time. | ||
regExp.lastIndex = 0; | ||
return { re: regExp, input: input }; | ||
} | ||
static replaceAll(regExp, input, replace) { | ||
let c = regExp.exec(input); | ||
let res = ''; | ||
regExp.lastIndex = 0; | ||
let prev = 0; | ||
while (c) { | ||
res += input.substring(prev, c.index); | ||
res += replace(c); | ||
prev = c.index + c[0].length; | ||
regExp.lastIndex = prev; | ||
c = regExp.exec(input); | ||
} | ||
res += input.substring(prev); | ||
return res; | ||
} | ||
} | ||
export class RegExpMatcherWrapper { | ||
static next(matcher) { | ||
return matcher.re.exec(matcher.input); | ||
} | ||
} | ||
export class FunctionWrapper { | ||
@@ -275,0 +234,0 @@ static apply(fn, posArgs) { return fn.apply(null, posArgs); } |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"IS_DART":false,"Type":{"__symbolic":"reference","name":"Function"},"Math":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Math"},"Date":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Date"},"isPresent":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBoolean":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":106,"character":8},"right":"boolean"}},"isNumber":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":110,"character":8},"right":"number"}},"isString":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":114,"character":8},"right":"string"}},"isFunction":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":118,"character":8},"right":"function"}},"isType":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":126,"character":8},"right":"object"},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isStrictStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isStringMap"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Object"},"member":"getPrototypeOf"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"reference","name":"STRING_MAP_PROTO"}}}},"isPromise":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Promise"}}},"isArray":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Array"},"member":"isArray"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isDate":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"Date"}},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"valueOf"}}]}}}},"serializeEnum":{"__symbolic":"function","parameters":["val"],"value":{"__symbolic":"reference","name":"val"}},"deserializeEnum":{"__symbolic":"function","parameters":["val","values"],"value":{"__symbolic":"reference","name":"val"}},"resolveEnumToken":{"__symbolic":"function","parameters":["enumValue","val"],"value":{"__symbolic":"index","expression":{"__symbolic":"reference","name":"enumValue"},"index":{"__symbolic":"reference","name":"val"}}},"RegExp":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"RegExp"},"looseIdentical":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}},"right":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":366,"character":19},"right":"number"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":366,"character":44},"right":"number"}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"a"}]}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"b"}]}}}},"getMapKey":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"reference","name":"value"}},"normalizeBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"error","message":"Expression form not supported","line":376,"character":8}},"normalizeBool":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"error","message":"Expression form not supported","line":380,"character":8}},"isJsObject":{"__symbolic":"function","parameters":["o"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"o"},"right":null},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":384,"character":24},"right":"function"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":384,"character":50},"right":"object"}}}},"isPrimitive":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isJsObject"},"arguments":[{"__symbolic":"reference","name":"obj"}]}}},"hasConstructor":{"__symbolic":"function","parameters":["value","type"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"constructor"},"right":{"__symbolic":"reference","name":"type"}}},"escape":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"encodeURI"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"escapeRegExp":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Expression form not supported","line":481,"character":19}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"Type":{"__symbolic":"reference","name":"Function"},"Math":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"Date":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"isPresent":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBoolean":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":104,"character":8},"right":"boolean"}},"isNumber":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":108,"character":8},"right":"number"}},"isString":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":112,"character":8},"right":"string"}},"isFunction":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":116,"character":8},"right":"function"}},"isType":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":124,"character":8},"right":"object"},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isStrictStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isStringMap"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Object"},"member":"getPrototypeOf"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"error","message":"Reference to a local symbol","line":127,"character":5,"context":{"name":"STRING_MAP_PROTO"}}}}},"isPromise":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isPresent"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"then"}]}}},"isArray":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Array"},"member":"isArray"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isDate":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"Date"}},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"valueOf"}}]}}}},"serializeEnum":{"__symbolic":"function","parameters":["val"],"value":{"__symbolic":"reference","name":"val"}},"deserializeEnum":{"__symbolic":"function","parameters":["val","values"],"value":{"__symbolic":"reference","name":"val"}},"resolveEnumToken":{"__symbolic":"function","parameters":["enumValue","val"],"value":{"__symbolic":"index","expression":{"__symbolic":"reference","name":"enumValue"},"index":{"__symbolic":"reference","name":"val"}}},"RegExp":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"looseIdentical":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}},"right":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":322,"character":19},"right":"number"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":322,"character":44},"right":"number"}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"a"}]}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"b"}]}}}},"getMapKey":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"reference","name":"value"}},"normalizeBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"if","condition":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isBlank"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"thenExpression":null,"elseExpression":{"__symbolic":"reference","name":"obj"}}},"normalizeBool":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"if","condition":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isBlank"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"thenExpression":false,"elseExpression":{"__symbolic":"reference","name":"obj"}}},"isJsObject":{"__symbolic":"function","parameters":["o"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"o"},"right":null},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":340,"character":24},"right":"function"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":340,"character":50},"right":"object"}}}},"isPrimitive":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isJsObject"},"arguments":[{"__symbolic":"reference","name":"obj"}]}}},"hasConstructor":{"__symbolic":"function","parameters":["value","type"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"constructor"},"right":{"__symbolic":"reference","name":"type"}}},"escape":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}}},"escapeRegExp":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Expression form not supported","line":437,"character":19}}}} |
@@ -8,5 +8,5 @@ /** | ||
*/ | ||
import { ListWrapper, Map, MapWrapper, StringMapWrapper, isListLikeIterable, iterateListLike } from '../src/facade/collection'; | ||
import { BaseException } from '../src/facade/exceptions'; | ||
import { isBlank } from '../src/facade/lang'; | ||
import { isListLikeIterable, iterateListLike, Map, MapWrapper, StringMapWrapper, ListWrapper } from '../src/facade/collection'; | ||
/** | ||
@@ -52,3 +52,3 @@ * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as | ||
StringMapWrapper.forEach(headers, (v, k) => { | ||
this._headersMap.set(k, isListLikeIterable(v) ? v : [v]); | ||
this._headersMap.set(normalize(k), isListLikeIterable(v) ? v : [v]); | ||
}); | ||
@@ -60,7 +60,12 @@ } | ||
static fromResponseHeaderString(headersString) { | ||
return headersString.trim() | ||
.split('\n') | ||
.map(val => val.split(':')) | ||
.map(([key, ...parts]) => ([key.trim(), parts.join(':').trim()])) | ||
.reduce((headers, [key, value]) => !headers.set(key, value) && headers, new Headers()); | ||
let headers = new Headers(); | ||
headersString.split('\n').forEach(line => { | ||
const index = line.indexOf(':'); | ||
if (index > 0) { | ||
const key = line.substring(0, index); | ||
const value = line.substring(index + 1).trim(); | ||
headers.set(key, value); | ||
} | ||
}); | ||
return headers; | ||
} | ||
@@ -71,2 +76,3 @@ /** | ||
append(name, value) { | ||
name = normalize(name); | ||
var mapName = this._headersMap.get(name); | ||
@@ -80,3 +86,3 @@ var list = isListLikeIterable(mapName) ? mapName : []; | ||
*/ | ||
delete(name) { this._headersMap.delete(name); } | ||
delete(name) { this._headersMap.delete(normalize(name)); } | ||
forEach(fn) { | ||
@@ -88,7 +94,7 @@ this._headersMap.forEach(fn); | ||
*/ | ||
get(header) { return ListWrapper.first(this._headersMap.get(header)); } | ||
get(header) { return ListWrapper.first(this._headersMap.get(normalize(header))); } | ||
/** | ||
* Check for existence of header by given name. | ||
*/ | ||
has(header) { return this._headersMap.has(header); } | ||
has(header) { return this._headersMap.has(normalize(header)); } | ||
/** | ||
@@ -110,3 +116,3 @@ * Provides names of set headers | ||
} | ||
this._headersMap.set(header, list); | ||
this._headersMap.set(normalize(header), list); | ||
} | ||
@@ -125,3 +131,3 @@ /** | ||
iterateListLike(values, (val /** TODO #9100 */) => list = ListWrapper.concat(list, val.split(','))); | ||
serializableHeaders[name] = list; | ||
serializableHeaders[normalize(name)] = list; | ||
}); | ||
@@ -134,3 +140,3 @@ return serializableHeaders; | ||
getAll(header) { | ||
var headers = this._headersMap.get(header); | ||
var headers = this._headersMap.get(normalize(header)); | ||
return isListLikeIterable(headers) ? headers : []; | ||
@@ -143,2 +149,9 @@ } | ||
} | ||
// "HTTP character sets are identified by case-insensitive tokens" | ||
// Spec at https://tools.ietf.org/html/rfc2616 | ||
// This implementation is same as NodeJS. | ||
// see https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_message_headers | ||
function normalize(name) { | ||
return name.toLowerCase(); | ||
} | ||
//# sourceMappingURL=headers.js.map |
@@ -5,2 +5,3 @@ import { RequestMethod } from './enums'; | ||
export declare function getResponseURL(xhr: any): string; | ||
export declare function stringToArrayBuffer(input: String): ArrayBuffer; | ||
export { isJsObject } from '../src/facade/lang'; |
@@ -32,3 +32,10 @@ /** | ||
} | ||
export function stringToArrayBuffer(input) { | ||
let view = new Uint16Array(input.length); | ||
for (var i = 0, strLen = input.length; i < strLen; i++) { | ||
view[i] = input.charCodeAt(i); | ||
} | ||
return view.buffer; | ||
} | ||
export { isJsObject } from '../src/facade/lang'; | ||
//# sourceMappingURL=http_utils.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":28,"character":24}}} | ||
{"__symbolic":"module","version":1,"metadata":{"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":28,"character":24}},"exports":[{"from":"../src/facade/lang","export":["isJsObject"]}]} |
@@ -101,2 +101,6 @@ import { Observable } from 'rxjs/Observable'; | ||
head(url: string, options?: RequestOptionsArgs): Observable<Response>; | ||
/** | ||
* Performs a request with `options` http method. | ||
*/ | ||
options(url: string, options?: RequestOptionsArgs): Observable<Response>; | ||
} | ||
@@ -103,0 +107,0 @@ /** |
@@ -28,3 +28,4 @@ /** | ||
body: providedOpts.body, | ||
withCredentials: providedOpts.withCredentials | ||
withCredentials: providedOpts.withCredentials, | ||
responseType: providedOpts.responseType | ||
})); | ||
@@ -99,2 +100,8 @@ } | ||
} | ||
/** | ||
* Performs a request with `options` http method. | ||
*/ | ||
options(url, options) { | ||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url))); | ||
} | ||
} | ||
@@ -101,0 +108,0 @@ /** @nocollapse */ |
@@ -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"}]}},"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":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"}]}}}} |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { ReadyState, RequestMethod, ResponseType } from './enums'; | ||
import { ReadyState, RequestMethod, ResponseContentType, ResponseType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -55,2 +55,3 @@ import { Request } from './static_request'; | ||
withCredentials?: boolean; | ||
responseType?: ResponseContentType; | ||
} | ||
@@ -70,3 +71,3 @@ /** | ||
export declare type ResponseOptionsArgs = { | ||
body?: string | Object | FormData; | ||
body?: string | Object | FormData | ArrayBuffer | Blob; | ||
status?: number; | ||
@@ -73,0 +74,0 @@ statusText?: string; |
@@ -1,2 +0,3 @@ | ||
import { ContentType, RequestMethod } from './enums'; | ||
import { Body } from './body'; | ||
import { ContentType, RequestMethod, ResponseContentType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -43,3 +44,3 @@ import { RequestArgs } from './interfaces'; | ||
*/ | ||
export declare class Request { | ||
export declare class Request extends Body { | ||
/** | ||
@@ -55,4 +56,2 @@ * Http method with which to perform the request. | ||
url: string; | ||
/** Body of the request **/ | ||
private _body; | ||
/** Type of the request body **/ | ||
@@ -62,31 +61,13 @@ private contentType; | ||
withCredentials: boolean; | ||
/** Buffer to store the response */ | ||
responseType: ResponseContentType; | ||
constructor(requestOptions: RequestArgs); | ||
/** | ||
* Returns the request's body as string, assuming that body exists. If body is undefined, return | ||
* empty | ||
* string. | ||
* Returns the content type enum based on header options. | ||
*/ | ||
text(): string; | ||
detectContentType(): ContentType; | ||
/** | ||
* Returns the request's body as JSON string, assuming that body exists. If body is undefined, | ||
* return | ||
* empty | ||
* string. | ||
*/ | ||
json(): string; | ||
/** | ||
* Returns the request's body as array buffer, assuming that body exists. If body is undefined, | ||
* return | ||
* null. | ||
*/ | ||
arrayBuffer(): ArrayBuffer; | ||
/** | ||
* Returns the request's body as blob, assuming that body exists. If body is undefined, return | ||
* null. | ||
*/ | ||
blob(): Blob; | ||
/** | ||
* Returns the content type of request's body based on its type. | ||
*/ | ||
detectContentType(): ContentType; | ||
detectContentTypeFromBody(): ContentType; | ||
/** | ||
@@ -93,0 +74,0 @@ * Returns the request's body according to its type. If body is undefined, return |
@@ -9,2 +9,3 @@ /** | ||
import { StringWrapper, isPresent } from '../src/facade/lang'; | ||
import { Body } from './body'; | ||
import { ContentType } from './enums'; | ||
@@ -54,4 +55,5 @@ import { Headers } from './headers'; | ||
*/ | ||
export class Request { | ||
export class Request extends Body { | ||
constructor(requestOptions) { | ||
super(); | ||
// TODO: assert that url is present | ||
@@ -72,3 +74,2 @@ let url = requestOptions.url; | ||
this._body = requestOptions.body; | ||
this.contentType = this.detectContentType(); | ||
this.method = normalizeMethodName(requestOptions.method); | ||
@@ -79,42 +80,30 @@ // TODO(jeffbcross): implement behavior | ||
this.headers = new Headers(requestOptions.headers); | ||
this.contentType = this.detectContentType(); | ||
this.withCredentials = requestOptions.withCredentials; | ||
this.responseType = requestOptions.responseType; | ||
} | ||
/** | ||
* Returns the request's body as string, assuming that body exists. If body is undefined, return | ||
* empty | ||
* string. | ||
* Returns the content type enum based on header options. | ||
*/ | ||
text() { return isPresent(this._body) ? this._body.toString() : ''; } | ||
/** | ||
* Returns the request's body as JSON string, assuming that body exists. If body is undefined, | ||
* return | ||
* empty | ||
* string. | ||
*/ | ||
json() { return isPresent(this._body) ? JSON.stringify(this._body) : ''; } | ||
/** | ||
* Returns the request's body as array buffer, assuming that body exists. If body is undefined, | ||
* return | ||
* null. | ||
*/ | ||
arrayBuffer() { | ||
if (this._body instanceof ArrayBuffer) | ||
return this._body; | ||
throw 'The request body isn\'t an array buffer'; | ||
detectContentType() { | ||
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(); | ||
} | ||
} | ||
/** | ||
* Returns the request's body as blob, assuming that body exists. If body is undefined, return | ||
* null. | ||
*/ | ||
blob() { | ||
if (this._body instanceof Blob) | ||
return this._body; | ||
if (this._body instanceof ArrayBuffer) | ||
return new Blob([this._body]); | ||
throw 'The request body isn\'t either a blob or an array buffer'; | ||
} | ||
/** | ||
* Returns the content type of request's body based on its type. | ||
*/ | ||
detectContentType() { | ||
detectContentTypeFromBody() { | ||
if (this._body == null) { | ||
@@ -149,3 +138,3 @@ return ContentType.NONE; | ||
case ContentType.JSON: | ||
return this.json(); | ||
return this.text(); | ||
case ContentType.FORM: | ||
@@ -152,0 +141,0 @@ return this.text(); |
import { ResponseOptions } from './base_response_options'; | ||
import { Body } from './body'; | ||
import { ResponseType } from './enums'; | ||
@@ -24,3 +25,3 @@ import { Headers } from './headers'; | ||
*/ | ||
export declare class Response { | ||
export declare class Response extends Body { | ||
/** | ||
@@ -73,21 +74,4 @@ * One of "basic", "cors", "default", "error, or "opaque". | ||
headers: Headers; | ||
private _body; | ||
constructor(responseOptions: ResponseOptions); | ||
/** | ||
* Not yet implemented | ||
*/ | ||
blob(): any; | ||
/** | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
*/ | ||
json(): any; | ||
/** | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
*/ | ||
text(): string; | ||
/** | ||
* Not yet implemented | ||
*/ | ||
arrayBuffer(): any; | ||
toString(): string; | ||
} |
@@ -8,5 +8,3 @@ /** | ||
*/ | ||
import { BaseException } from '../src/facade/exceptions'; | ||
import { Json, isString } from '../src/facade/lang'; | ||
import { isJsObject } from './http_utils'; | ||
import { Body } from './body'; | ||
/** | ||
@@ -32,4 +30,5 @@ * Creates `Response` instances from provided values. | ||
*/ | ||
export class Response { | ||
export class Response extends Body { | ||
constructor(responseOptions) { | ||
super(); | ||
this._body = responseOptions.body; | ||
@@ -43,31 +42,2 @@ this.status = responseOptions.status; | ||
} | ||
/** | ||
* Not yet implemented | ||
*/ | ||
// TODO: Blob return type | ||
blob() { throw new BaseException('"blob()" method not implemented on Response superclass'); } | ||
/** | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
*/ | ||
json() { | ||
var jsonResponse; | ||
if (isJsObject(this._body)) { | ||
jsonResponse = this._body; | ||
} | ||
else if (isString(this._body)) { | ||
jsonResponse = Json.parse(this._body); | ||
} | ||
return jsonResponse; | ||
} | ||
/** | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
*/ | ||
text() { return this._body.toString(); } | ||
/** | ||
* Not yet implemented | ||
*/ | ||
// TODO: ArrayBuffer return type | ||
arrayBuffer() { | ||
throw new BaseException('"arrayBuffer()" method not implemented on Response superclass'); | ||
} | ||
toString() { | ||
@@ -74,0 +44,0 @@ return `Response with status: ${this.status} ${this.statusText} for URL: ${this.url}`; |
@@ -11,10 +11,9 @@ /** | ||
function paramParser(rawParams = '') { | ||
var map = new Map(); | ||
const map = new Map(); | ||
if (rawParams.length > 0) { | ||
var params = rawParams.split('&'); | ||
const params = rawParams.split('&'); | ||
params.forEach((param) => { | ||
var split = param.split('=', 2); | ||
var key = split[0]; | ||
var val = split[1]; | ||
var list = isPresent(map.get(key)) ? map.get(key) : []; | ||
const eqIdx = param.indexOf('='); | ||
const [key, val] = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)]; | ||
const list = map.get(key) || []; | ||
list.push(val); | ||
@@ -87,3 +86,3 @@ map.set(key, list); | ||
clone() { | ||
var clone = new URLSearchParams(); | ||
var clone = new URLSearchParams('', this.queryEncoder); | ||
clone.appendAll(this); | ||
@@ -90,0 +89,0 @@ return clone; |
@@ -1,2 +0,2 @@ | ||
import { XHRBackend } from './src/backends/xhr_backend'; | ||
import { CookieXSRFStrategy, XHRBackend } from './src/backends/xhr_backend'; | ||
import { RequestOptions } from './src/base_request_options'; | ||
@@ -9,3 +9,3 @@ import { Http } from './src/http'; | ||
export { BaseResponseOptions, ResponseOptions } from './src/base_response_options'; | ||
export { ReadyState, RequestMethod, ResponseType } from './src/enums'; | ||
export { ReadyState, RequestMethod, ResponseContentType, ResponseType } from './src/enums'; | ||
export { Headers } from './src/headers'; | ||
@@ -160,3 +160,3 @@ export { Http, Jsonp } from './src/http'; | ||
* | ||
* @experimental | ||
* @deprecated | ||
*/ | ||
@@ -167,2 +167,6 @@ export declare const HTTP_PROVIDERS: any[]; | ||
*/ | ||
export declare function _createDefaultCookieXSRFStrategy(): CookieXSRFStrategy; | ||
/** | ||
* @experimental | ||
*/ | ||
export declare function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http; | ||
@@ -291,1 +295,15 @@ /** | ||
export declare const JSON_BINDINGS: any[]; | ||
/** | ||
* The module that includes http's providers | ||
* | ||
* @experimental | ||
*/ | ||
export declare class HttpModule { | ||
} | ||
/** | ||
* The module that includes jsonp's providers | ||
* | ||
* @experimental | ||
*/ | ||
export declare class JsonpModule { | ||
} |
39
http.js
@@ -9,2 +9,9 @@ /** | ||
"use strict"; | ||
/** | ||
* @module | ||
* @description | ||
* The http module provides services to perform http requests. To get started, see the {@link Http} | ||
* class. | ||
*/ | ||
var core_1 = require('@angular/core'); | ||
var browser_jsonp_1 = require('./src/backends/browser_jsonp'); | ||
@@ -36,2 +43,3 @@ var browser_xhr_1 = require('./src/backends/browser_xhr'); | ||
exports.RequestMethod = enums_1.RequestMethod; | ||
exports.ResponseContentType = enums_1.ResponseContentType; | ||
exports.ResponseType = enums_1.ResponseType; | ||
@@ -197,3 +205,3 @@ var headers_1 = require('./src/headers'); | ||
* | ||
* @experimental | ||
* @deprecated | ||
*/ | ||
@@ -208,3 +216,3 @@ exports.HTTP_PROVIDERS = [ | ||
xhr_backend_1.XHRBackend, | ||
{ provide: interfaces_1.XSRFStrategy, useValue: new xhr_backend_1.CookieXSRFStrategy() }, | ||
{ provide: interfaces_1.XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy }, | ||
]; | ||
@@ -214,2 +222,9 @@ /** | ||
*/ | ||
function _createDefaultCookieXSRFStrategy() { | ||
return new xhr_backend_1.CookieXSRFStrategy(); | ||
} | ||
exports._createDefaultCookieXSRFStrategy = _createDefaultCookieXSRFStrategy; | ||
/** | ||
* @experimental | ||
*/ | ||
function httpFactory(xhrBackend, requestOptions) { | ||
@@ -352,2 +367,22 @@ return new http_1.Http(xhrBackend, requestOptions); | ||
exports.JSON_BINDINGS = exports.JSONP_PROVIDERS; | ||
var HttpModule = (function () { | ||
function HttpModule() { | ||
} | ||
/** @nocollapse */ | ||
HttpModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ providers: exports.HTTP_PROVIDERS },] }, | ||
]; | ||
return HttpModule; | ||
}()); | ||
exports.HttpModule = HttpModule; | ||
var JsonpModule = (function () { | ||
function JsonpModule() { | ||
} | ||
/** @nocollapse */ | ||
JsonpModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ providers: exports.JSONP_PROVIDERS },] }, | ||
]; | ||
return JsonpModule; | ||
}()); | ||
exports.JsonpModule = JsonpModule; | ||
//# sourceMappingURL=http.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"HTTP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./src/interfaces","name":"XSRFStrategy"},"useValue":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"CookieXSRFStrategy"}}}],"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HTTP_BINDINGS":{"__symbolic":"reference","name":"HTTP_PROVIDERS"},"JSONP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend_"}}],"JSON_BINDINGS":{"__symbolic":"reference","name":"JSONP_PROVIDERS"}}} | ||
{"__symbolic":"module","version":1,"metadata":{"HTTP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Http"},"useFactory":{"__symbolic":"reference","name":"httpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_xhr","name":"BrowserXhr"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"XHRBackend"},{"provide":{"__symbolic":"reference","module":"./src/interfaces","name":"XSRFStrategy"},"useFactory":{"__symbolic":"reference","name":"_createDefaultCookieXSRFStrategy"}}],"_createDefaultCookieXSRFStrategy":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/backends/xhr_backend","name":"CookieXSRFStrategy"}}},"httpFactory":{"__symbolic":"function","parameters":["xhrBackend","requestOptions"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"./src/http","name":"Http"},"arguments":[{"__symbolic":"reference","name":"xhrBackend"},{"__symbolic":"reference","name":"requestOptions"}]}},"HTTP_BINDINGS":{"__symbolic":"reference","name":"HTTP_PROVIDERS"},"JSONP_PROVIDERS":[{"provide":{"__symbolic":"reference","module":"./src/http","name":"Jsonp"},"useFactory":{"__symbolic":"reference","name":"jsonpFactory"},"deps":[{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"}]},{"__symbolic":"reference","module":"./src/backends/browser_jsonp","name":"BrowserJsonp"},{"provide":{"__symbolic":"reference","module":"./src/base_request_options","name":"RequestOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_request_options","name":"BaseRequestOptions"}},{"provide":{"__symbolic":"reference","module":"./src/base_response_options","name":"ResponseOptions"},"useClass":{"__symbolic":"reference","module":"./src/base_response_options","name":"BaseResponseOptions"}},{"provide":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend"},"useClass":{"__symbolic":"reference","module":"./src/backends/jsonp_backend","name":"JSONPBackend_"}}],"JSON_BINDINGS":{"__symbolic":"reference","name":"JSONP_PROVIDERS"},"HttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":{"__symbolic":"reference","name":"HTTP_PROVIDERS"}}]}]},"JsonpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":{"__symbolic":"reference","name":"JSONP_PROVIDERS"}}]}]}},"exports":[{"from":"./src/backends/browser_xhr","export":["BrowserXhr"]},{"from":"./src/backends/jsonp_backend","export":["JSONPBackend","JSONPConnection"]},{"from":"./src/backends/xhr_backend","export":["CookieXSRFStrategy","XHRBackend","XHRConnection"]},{"from":"./src/base_request_options","export":["BaseRequestOptions","RequestOptions"]},{"from":"./src/base_response_options","export":["BaseResponseOptions","ResponseOptions"]},{"from":"./src/enums","export":["ReadyState","RequestMethod","ResponseContentType","ResponseType"]},{"from":"./src/headers","export":["Headers"]},{"from":"./src/http","export":["Http","Jsonp"]},{"from":"./src/interfaces","export":["Connection","ConnectionBackend","RequestOptionsArgs","ResponseOptionsArgs","XSRFStrategy"]},{"from":"./src/static_request","export":["Request"]},{"from":"./src/static_response","export":["Response"]},{"from":"./src/url_search_params","export":["QueryEncoder","URLSearchParams"]}]} |
{ | ||
"name": "@angular/http", | ||
"version": "2.0.0-rc.4", | ||
"version": "2.0.0-rc.5", | ||
"description": "", | ||
@@ -12,4 +12,4 @@ "main": "index.js", | ||
"rxjs": "5.0.0-beta.6", | ||
"@angular/core": "^2.0.0-rc.4", | ||
"@angular/platform-browser": "^2.0.0-rc.4" | ||
"@angular/core": "^2.0.0-rc.5", | ||
"@angular/platform-browser": "^2.0.0-rc.5" | ||
}, | ||
@@ -16,0 +16,0 @@ "repository": { |
@@ -31,4 +31,4 @@ import { Observable } from 'rxjs/Observable'; | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) for more | ||
* information on XSRF. | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* | ||
@@ -35,0 +35,0 @@ * Applications can configure custom cookie and header names by binding an instance of this class |
@@ -92,2 +92,21 @@ /** | ||
} | ||
// Select the correct buffer type to store the response | ||
if (lang_1.isPresent(req.responseType) && lang_1.isPresent(_xhr.responseType)) { | ||
switch (req.responseType) { | ||
case enums_1.ResponseContentType.ArrayBuffer: | ||
_xhr.responseType = 'arraybuffer'; | ||
break; | ||
case enums_1.ResponseContentType.Json: | ||
_xhr.responseType = 'json'; | ||
break; | ||
case enums_1.ResponseContentType.Text: | ||
_xhr.responseType = 'text'; | ||
break; | ||
case enums_1.ResponseContentType.Blob: | ||
_xhr.responseType = 'blob'; | ||
break; | ||
default: | ||
throw new Error('The selected responseType is not supported'); | ||
} | ||
} | ||
_xhr.addEventListener('load', onLoad); | ||
@@ -113,9 +132,9 @@ _xhr.addEventListener('error', onError); | ||
case enums_1.ContentType.JSON: | ||
_xhr.setRequestHeader('Content-Type', 'application/json'); | ||
_xhr.setRequestHeader('content-type', 'application/json'); | ||
break; | ||
case enums_1.ContentType.FORM: | ||
_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
_xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
break; | ||
case enums_1.ContentType.TEXT: | ||
_xhr.setRequestHeader('Content-Type', 'text/plain'); | ||
_xhr.setRequestHeader('content-type', 'text/plain'); | ||
break; | ||
@@ -125,3 +144,3 @@ case enums_1.ContentType.BLOB: | ||
if (blob.type) { | ||
_xhr.setRequestHeader('Content-Type', blob.type); | ||
_xhr.setRequestHeader('content-type', blob.type); | ||
} | ||
@@ -136,4 +155,4 @@ break; | ||
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application | ||
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) for more | ||
* information on XSRF. | ||
* using a cookie. See {@link https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)} | ||
* for more information on XSRF. | ||
* | ||
@@ -140,0 +159,0 @@ * Applications can configure custom cookie and header names by binding an instance of this class |
@@ -1,2 +0,2 @@ | ||
import { RequestMethod } from './enums'; | ||
import { RequestMethod, ResponseContentType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -57,3 +57,4 @@ import { RequestOptionsArgs } from './interfaces'; | ||
withCredentials: boolean; | ||
constructor({method, headers, body, url, search, withCredentials}?: RequestOptionsArgs); | ||
responseType: ResponseContentType; | ||
constructor({method, headers, body, url, search, withCredentials, responseType}?: RequestOptionsArgs); | ||
/** | ||
@@ -60,0 +61,0 @@ * Creates a copy of the `RequestOptions` instance, using the optional input as values to override |
@@ -48,3 +48,3 @@ /** | ||
function RequestOptions(_a) { | ||
var _b = _a === void 0 ? {} : _a, method = _b.method, headers = _b.headers, body = _b.body, url = _b.url, search = _b.search, withCredentials = _b.withCredentials; | ||
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; | ||
this.method = lang_1.isPresent(method) ? http_utils_1.normalizeMethodName(method) : null; | ||
@@ -58,2 +58,3 @@ this.headers = lang_1.isPresent(headers) ? headers : null; | ||
this.withCredentials = lang_1.isPresent(withCredentials) ? withCredentials : null; | ||
this.responseType = lang_1.isPresent(responseType) ? responseType : null; | ||
} | ||
@@ -97,3 +98,5 @@ /** | ||
options.withCredentials : | ||
this.withCredentials | ||
this.withCredentials, | ||
responseType: lang_1.isPresent(options) && lang_1.isPresent(options.responseType) ? options.responseType : | ||
this.responseType | ||
}); | ||
@@ -100,0 +103,0 @@ }; |
@@ -33,5 +33,5 @@ import { Headers } from './headers'; | ||
/** | ||
* String or Object representing the body of the {@link Response}. | ||
* String, Object, ArrayBuffer or Blob representing the body of the {@link Response}. | ||
*/ | ||
body: string | Object; | ||
body: string | Object | ArrayBuffer | Blob; | ||
/** | ||
@@ -38,0 +38,0 @@ * Http {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html status code} |
@@ -60,1 +60,11 @@ /** | ||
} | ||
/** | ||
* Define which buffer to use to store the response | ||
* @experimental | ||
*/ | ||
export declare enum ResponseContentType { | ||
Text = 0, | ||
Json = 1, | ||
ArrayBuffer = 2, | ||
Blob = 3, | ||
} |
@@ -65,2 +65,13 @@ /** | ||
var ContentType = exports.ContentType; | ||
/** | ||
* Define which buffer to use to store the response | ||
* @experimental | ||
*/ | ||
(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 = {})); | ||
var ResponseContentType = exports.ResponseContentType; | ||
//# sourceMappingURL=enums.js.map |
@@ -47,3 +47,3 @@ export declare var Map: MapConstructor; | ||
[key: string]: V; | ||
}, callback: Function): void; | ||
}, callback: (v: V, K: string) => void): void; | ||
static merge<V>(m1: { | ||
@@ -50,0 +50,0 @@ [key: string]: V; |
@@ -127,6 +127,3 @@ /** | ||
StringMapWrapper.values = function (map) { | ||
return Object.keys(map).reduce(function (r, a) { | ||
r.push(map[a]); | ||
return r; | ||
}, []); | ||
return Object.keys(map).map(function (k) { return map[k]; }); | ||
}; | ||
@@ -141,6 +138,5 @@ StringMapWrapper.isEmpty = function (map) { | ||
StringMapWrapper.forEach = function (map, callback) { | ||
for (var prop in map) { | ||
if (map.hasOwnProperty(prop)) { | ||
callback(map[prop], prop); | ||
} | ||
for (var _i = 0, _a = Object.keys(map); _i < _a.length; _i++) { | ||
var k = _a[_i]; | ||
callback(map[k], k); | ||
} | ||
@@ -150,11 +146,9 @@ }; | ||
var m = {}; | ||
for (var attr in m1) { | ||
if (m1.hasOwnProperty(attr)) { | ||
m[attr] = m1[attr]; | ||
} | ||
for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) { | ||
var k = _a[_i]; | ||
m[k] = m1[k]; | ||
} | ||
for (var attr in m2) { | ||
if (m2.hasOwnProperty(attr)) { | ||
m[attr] = m2[attr]; | ||
} | ||
for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) { | ||
var k = _c[_b]; | ||
m[k] = m2[k]; | ||
} | ||
@@ -161,0 +155,0 @@ return m; |
@@ -18,3 +18,3 @@ /** | ||
* | ||
* bootstrap(MyApp, {provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* bootstrap(MyApp, [{provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* | ||
@@ -21,0 +21,0 @@ * ``` |
@@ -40,3 +40,3 @@ /** | ||
* | ||
* bootstrap(MyApp, {provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* bootstrap(MyApp, [{provide: ExceptionHandler, useClass: MyExceptionHandler}]) | ||
* | ||
@@ -43,0 +43,0 @@ * ``` |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"makeTypeError":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"TypeError"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"makeTypeError":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"TypeError"},"arguments":[{"__symbolic":"reference","name":"message"}]}}},"exports":[{"from":"./exception_handler","export":["ExceptionHandler"]}]} |
@@ -30,3 +30,2 @@ /** | ||
export declare function scheduleMicroTask(fn: Function): void; | ||
export declare const IS_DART: boolean; | ||
declare var _global: BrowserNodeGlobal; | ||
@@ -109,18 +108,2 @@ export { _global as global }; | ||
export declare var RegExp: RegExpConstructor; | ||
export declare class RegExpWrapper { | ||
static create(regExpStr: string, flags?: string): RegExp; | ||
static firstMatch(regExp: RegExp, input: string): RegExpExecArray; | ||
static test(regExp: RegExp, input: string): boolean; | ||
static matcher(regExp: RegExp, input: string): { | ||
re: RegExp; | ||
input: string; | ||
}; | ||
static replaceAll(regExp: RegExp, input: string, replace: Function): string; | ||
} | ||
export declare class RegExpMatcherWrapper { | ||
static next(matcher: { | ||
re: RegExp; | ||
input: string; | ||
}): RegExpExecArray; | ||
} | ||
export declare class FunctionWrapper { | ||
@@ -127,0 +110,0 @@ static apply(fn: Function, posArgs: any): any; |
@@ -31,3 +31,2 @@ /** | ||
exports.scheduleMicroTask = scheduleMicroTask; | ||
exports.IS_DART = false; | ||
// Need to declare a new variable for global here since TypeScript | ||
@@ -99,3 +98,5 @@ // exports the original value of the symbol. | ||
function isPromise(obj) { | ||
return obj instanceof _global.Promise; | ||
// allow any Promise/A+ compliant thenable. | ||
// It's up to the caller to ensure that obj.then conforms to the spec | ||
return isPresent(obj) && isFunction(obj.then); | ||
} | ||
@@ -120,8 +121,8 @@ exports.isPromise = isPromise; | ||
} | ||
if (token.overriddenName) { | ||
return token.overriddenName; | ||
} | ||
if (token.name) { | ||
return token.name; | ||
} | ||
if (token.overriddenName) { | ||
return token.overriddenName; | ||
} | ||
var res = token.toString(); | ||
@@ -280,53 +281,2 @@ var newLineIndex = res.indexOf('\n'); | ||
exports.RegExp = _global.RegExp; | ||
var RegExpWrapper = (function () { | ||
function RegExpWrapper() { | ||
} | ||
RegExpWrapper.create = function (regExpStr, flags) { | ||
if (flags === void 0) { flags = ''; } | ||
flags = flags.replace(/g/g, ''); | ||
return new _global.RegExp(regExpStr, flags + 'g'); | ||
}; | ||
RegExpWrapper.firstMatch = function (regExp, input) { | ||
// Reset multimatch regex state | ||
regExp.lastIndex = 0; | ||
return regExp.exec(input); | ||
}; | ||
RegExpWrapper.test = function (regExp, input) { | ||
regExp.lastIndex = 0; | ||
return regExp.test(input); | ||
}; | ||
RegExpWrapper.matcher = function (regExp, input) { | ||
// Reset regex state for the case | ||
// someone did not loop over all matches | ||
// last time. | ||
regExp.lastIndex = 0; | ||
return { re: regExp, input: input }; | ||
}; | ||
RegExpWrapper.replaceAll = function (regExp, input, replace) { | ||
var c = regExp.exec(input); | ||
var res = ''; | ||
regExp.lastIndex = 0; | ||
var prev = 0; | ||
while (c) { | ||
res += input.substring(prev, c.index); | ||
res += replace(c); | ||
prev = c.index + c[0].length; | ||
regExp.lastIndex = prev; | ||
c = regExp.exec(input); | ||
} | ||
res += input.substring(prev); | ||
return res; | ||
}; | ||
return RegExpWrapper; | ||
}()); | ||
exports.RegExpWrapper = RegExpWrapper; | ||
var RegExpMatcherWrapper = (function () { | ||
function RegExpMatcherWrapper() { | ||
} | ||
RegExpMatcherWrapper.next = function (matcher) { | ||
return matcher.re.exec(matcher.input); | ||
}; | ||
return RegExpMatcherWrapper; | ||
}()); | ||
exports.RegExpMatcherWrapper = RegExpMatcherWrapper; | ||
var FunctionWrapper = (function () { | ||
@@ -333,0 +283,0 @@ function FunctionWrapper() { |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"IS_DART":false,"Type":{"__symbolic":"reference","name":"Function"},"Math":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Math"},"Date":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Date"},"isPresent":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBoolean":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":106,"character":8},"right":"boolean"}},"isNumber":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":110,"character":8},"right":"number"}},"isString":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":114,"character":8},"right":"string"}},"isFunction":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":118,"character":8},"right":"function"}},"isType":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":126,"character":8},"right":"object"},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isStrictStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isStringMap"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Object"},"member":"getPrototypeOf"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"reference","name":"STRING_MAP_PROTO"}}}},"isPromise":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"Promise"}}},"isArray":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Array"},"member":"isArray"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isDate":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"Date"}},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"valueOf"}}]}}}},"serializeEnum":{"__symbolic":"function","parameters":["val"],"value":{"__symbolic":"reference","name":"val"}},"deserializeEnum":{"__symbolic":"function","parameters":["val","values"],"value":{"__symbolic":"reference","name":"val"}},"resolveEnumToken":{"__symbolic":"function","parameters":["enumValue","val"],"value":{"__symbolic":"index","expression":{"__symbolic":"reference","name":"enumValue"},"index":{"__symbolic":"reference","name":"val"}}},"RegExp":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"RegExp"},"looseIdentical":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}},"right":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":366,"character":19},"right":"number"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":366,"character":44},"right":"number"}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"a"}]}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"b"}]}}}},"getMapKey":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"reference","name":"value"}},"normalizeBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"error","message":"Expression form not supported","line":376,"character":8}},"normalizeBool":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"error","message":"Expression form not supported","line":380,"character":8}},"isJsObject":{"__symbolic":"function","parameters":["o"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"o"},"right":null},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":384,"character":24},"right":"function"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":384,"character":50},"right":"object"}}}},"isPrimitive":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isJsObject"},"arguments":[{"__symbolic":"reference","name":"obj"}]}}},"hasConstructor":{"__symbolic":"function","parameters":["value","type"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"constructor"},"right":{"__symbolic":"reference","name":"type"}}},"escape":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"_global"},"member":"encodeURI"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"escapeRegExp":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Expression form not supported","line":481,"character":19}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"Type":{"__symbolic":"reference","name":"Function"},"Math":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"Date":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"isPresent":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"undefined"}},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isBoolean":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":104,"character":8},"right":"boolean"}},"isNumber":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":108,"character":8},"right":"number"}},"isString":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":112,"character":8},"right":"string"}},"isFunction":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":116,"character":8},"right":"function"}},"isType":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":124,"character":8},"right":"object"},"right":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"obj"},"right":null}}},"isStrictStringMap":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isStringMap"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Object"},"member":"getPrototypeOf"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"error","message":"Reference to a local symbol","line":127,"character":5,"context":{"name":"STRING_MAP_PROTO"}}}}},"isPromise":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isPresent"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isFunction"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"then"}]}}},"isArray":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Array"},"member":"isArray"},"arguments":[{"__symbolic":"reference","name":"obj"}]}},"isDate":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"obj"},"right":{"__symbolic":"reference","name":"Date"}},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"obj"},"member":"valueOf"}}]}}}},"serializeEnum":{"__symbolic":"function","parameters":["val"],"value":{"__symbolic":"reference","name":"val"}},"deserializeEnum":{"__symbolic":"function","parameters":["val","values"],"value":{"__symbolic":"reference","name":"val"}},"resolveEnumToken":{"__symbolic":"function","parameters":["enumValue","val"],"value":{"__symbolic":"index","expression":{"__symbolic":"reference","name":"enumValue"},"index":{"__symbolic":"reference","name":"val"}}},"RegExp":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}},"looseIdentical":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}},"right":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":322,"character":19},"right":"number"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":322,"character":44},"right":"number"}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"a"}]}},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNaN"},"arguments":[{"__symbolic":"reference","name":"b"}]}}}},"getMapKey":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"reference","name":"value"}},"normalizeBlank":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"if","condition":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isBlank"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"thenExpression":null,"elseExpression":{"__symbolic":"reference","name":"obj"}}},"normalizeBool":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"if","condition":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isBlank"},"arguments":[{"__symbolic":"reference","name":"obj"}]},"thenExpression":false,"elseExpression":{"__symbolic":"reference","name":"obj"}}},"isJsObject":{"__symbolic":"function","parameters":["o"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"reference","name":"o"},"right":null},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":340,"character":24},"right":"function"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"error","message":"Expression form not supported","line":340,"character":50},"right":"object"}}}},"isPrimitive":{"__symbolic":"function","parameters":["obj"],"value":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isJsObject"},"arguments":[{"__symbolic":"reference","name":"obj"}]}}},"hasConstructor":{"__symbolic":"function","parameters":["value","type"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"constructor"},"right":{"__symbolic":"reference","name":"type"}}},"escape":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Reference to a local symbol","line":55,"character":3,"context":{"name":"_global"}}},"escapeRegExp":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"error","message":"Expression form not supported","line":437,"character":19}}}} |
@@ -9,5 +9,5 @@ /** | ||
"use strict"; | ||
var collection_1 = require('../src/facade/collection'); | ||
var exceptions_1 = require('../src/facade/exceptions'); | ||
var lang_1 = require('../src/facade/lang'); | ||
var collection_1 = require('../src/facade/collection'); | ||
/** | ||
@@ -54,3 +54,3 @@ * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as | ||
collection_1.StringMapWrapper.forEach(headers, function (v, k) { | ||
_this._headersMap.set(k, collection_1.isListLikeIterable(v) ? v : [v]); | ||
_this._headersMap.set(normalize(k), collection_1.isListLikeIterable(v) ? v : [v]); | ||
}); | ||
@@ -62,13 +62,12 @@ } | ||
Headers.fromResponseHeaderString = function (headersString) { | ||
return headersString.trim() | ||
.split('\n') | ||
.map(function (val) { return val.split(':'); }) | ||
.map(function (_a) { | ||
var key = _a[0], parts = _a.slice(1); | ||
return ([key.trim(), parts.join(':').trim()]); | ||
}) | ||
.reduce(function (headers, _a) { | ||
var key = _a[0], value = _a[1]; | ||
return !headers.set(key, value) && headers; | ||
}, new Headers()); | ||
var headers = new Headers(); | ||
headersString.split('\n').forEach(function (line) { | ||
var index = line.indexOf(':'); | ||
if (index > 0) { | ||
var key = line.substring(0, index); | ||
var value = line.substring(index + 1).trim(); | ||
headers.set(key, value); | ||
} | ||
}); | ||
return headers; | ||
}; | ||
@@ -79,2 +78,3 @@ /** | ||
Headers.prototype.append = function (name, value) { | ||
name = normalize(name); | ||
var mapName = this._headersMap.get(name); | ||
@@ -88,3 +88,3 @@ var list = collection_1.isListLikeIterable(mapName) ? mapName : []; | ||
*/ | ||
Headers.prototype.delete = function (name) { this._headersMap.delete(name); }; | ||
Headers.prototype.delete = function (name) { this._headersMap.delete(normalize(name)); }; | ||
Headers.prototype.forEach = function (fn) { | ||
@@ -96,7 +96,7 @@ this._headersMap.forEach(fn); | ||
*/ | ||
Headers.prototype.get = function (header) { return collection_1.ListWrapper.first(this._headersMap.get(header)); }; | ||
Headers.prototype.get = function (header) { return collection_1.ListWrapper.first(this._headersMap.get(normalize(header))); }; | ||
/** | ||
* Check for existence of header by given name. | ||
*/ | ||
Headers.prototype.has = function (header) { return this._headersMap.has(header); }; | ||
Headers.prototype.has = function (header) { return this._headersMap.has(normalize(header)); }; | ||
/** | ||
@@ -118,3 +118,3 @@ * Provides names of set headers | ||
} | ||
this._headersMap.set(header, list); | ||
this._headersMap.set(normalize(header), list); | ||
}; | ||
@@ -133,3 +133,3 @@ /** | ||
collection_1.iterateListLike(values, function (val /** TODO #9100 */) { return list = collection_1.ListWrapper.concat(list, val.split(',')); }); | ||
serializableHeaders[name] = list; | ||
serializableHeaders[normalize(name)] = list; | ||
}); | ||
@@ -142,3 +142,3 @@ return serializableHeaders; | ||
Headers.prototype.getAll = function (header) { | ||
var headers = this._headersMap.get(header); | ||
var headers = this._headersMap.get(normalize(header)); | ||
return collection_1.isListLikeIterable(headers) ? headers : []; | ||
@@ -153,2 +153,9 @@ }; | ||
exports.Headers = Headers; | ||
// "HTTP character sets are identified by case-insensitive tokens" | ||
// Spec at https://tools.ietf.org/html/rfc2616 | ||
// This implementation is same as NodeJS. | ||
// see https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_message_headers | ||
function normalize(name) { | ||
return name.toLowerCase(); | ||
} | ||
//# sourceMappingURL=headers.js.map |
@@ -5,2 +5,3 @@ import { RequestMethod } from './enums'; | ||
export declare function getResponseURL(xhr: any): string; | ||
export declare function stringToArrayBuffer(input: String): ArrayBuffer; | ||
export { isJsObject } from '../src/facade/lang'; |
@@ -35,4 +35,12 @@ /** | ||
exports.getResponseURL = getResponseURL; | ||
function stringToArrayBuffer(input) { | ||
var view = new Uint16Array(input.length); | ||
for (var i = 0, strLen = input.length; i < strLen; i++) { | ||
view[i] = input.charCodeAt(i); | ||
} | ||
return view.buffer; | ||
} | ||
exports.stringToArrayBuffer = stringToArrayBuffer; | ||
var lang_2 = require('../src/facade/lang'); | ||
exports.isJsObject = lang_2.isJsObject; | ||
//# sourceMappingURL=http_utils.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":28,"character":24}}} | ||
{"__symbolic":"module","version":1,"metadata":{"isSuccess":{"__symbolic":"error","message":"Function call not supported","line":28,"character":24}},"exports":[{"from":"../src/facade/lang","export":["isJsObject"]}]} |
@@ -101,2 +101,6 @@ import { Observable } from 'rxjs/Observable'; | ||
head(url: string, options?: RequestOptionsArgs): Observable<Response>; | ||
/** | ||
* Performs a request with `options` http method. | ||
*/ | ||
options(url: string, options?: RequestOptionsArgs): Observable<Response>; | ||
} | ||
@@ -103,0 +107,0 @@ /** |
@@ -34,3 +34,4 @@ /** | ||
body: providedOpts.body, | ||
withCredentials: providedOpts.withCredentials | ||
withCredentials: providedOpts.withCredentials, | ||
responseType: providedOpts.responseType | ||
})); | ||
@@ -105,2 +106,8 @@ } | ||
}; | ||
/** | ||
* Performs a request with `options` http method. | ||
*/ | ||
Http.prototype.options = function (url, options) { | ||
return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Options, url))); | ||
}; | ||
/** @nocollapse */ | ||
@@ -107,0 +114,0 @@ Http.decorators = [ |
@@ -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"}]}},"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":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"}]}}}} |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { ReadyState, RequestMethod, ResponseType } from './enums'; | ||
import { ReadyState, RequestMethod, ResponseContentType, ResponseType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -55,2 +55,3 @@ import { Request } from './static_request'; | ||
withCredentials?: boolean; | ||
responseType?: ResponseContentType; | ||
} | ||
@@ -70,3 +71,3 @@ /** | ||
export declare type ResponseOptionsArgs = { | ||
body?: string | Object | FormData; | ||
body?: string | Object | FormData | ArrayBuffer | Blob; | ||
status?: number; | ||
@@ -73,0 +74,0 @@ statusText?: string; |
@@ -1,2 +0,3 @@ | ||
import { ContentType, RequestMethod } from './enums'; | ||
import { Body } from './body'; | ||
import { ContentType, RequestMethod, ResponseContentType } from './enums'; | ||
import { Headers } from './headers'; | ||
@@ -43,3 +44,3 @@ import { RequestArgs } from './interfaces'; | ||
*/ | ||
export declare class Request { | ||
export declare class Request extends Body { | ||
/** | ||
@@ -55,4 +56,2 @@ * Http method with which to perform the request. | ||
url: string; | ||
/** Body of the request **/ | ||
private _body; | ||
/** Type of the request body **/ | ||
@@ -62,31 +61,13 @@ private contentType; | ||
withCredentials: boolean; | ||
/** Buffer to store the response */ | ||
responseType: ResponseContentType; | ||
constructor(requestOptions: RequestArgs); | ||
/** | ||
* Returns the request's body as string, assuming that body exists. If body is undefined, return | ||
* empty | ||
* string. | ||
* Returns the content type enum based on header options. | ||
*/ | ||
text(): string; | ||
detectContentType(): ContentType; | ||
/** | ||
* Returns the request's body as JSON string, assuming that body exists. If body is undefined, | ||
* return | ||
* empty | ||
* string. | ||
*/ | ||
json(): string; | ||
/** | ||
* Returns the request's body as array buffer, assuming that body exists. If body is undefined, | ||
* return | ||
* null. | ||
*/ | ||
arrayBuffer(): ArrayBuffer; | ||
/** | ||
* Returns the request's body as blob, assuming that body exists. If body is undefined, return | ||
* null. | ||
*/ | ||
blob(): Blob; | ||
/** | ||
* Returns the content type of request's body based on its type. | ||
*/ | ||
detectContentType(): ContentType; | ||
detectContentTypeFromBody(): ContentType; | ||
/** | ||
@@ -93,0 +74,0 @@ * Returns the request's body according to its type. If body is undefined, return |
@@ -9,3 +9,9 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var lang_1 = require('../src/facade/lang'); | ||
var body_1 = require('./body'); | ||
var enums_1 = require('./enums'); | ||
@@ -55,4 +61,6 @@ var headers_1 = require('./headers'); | ||
*/ | ||
var Request = (function () { | ||
var Request = (function (_super) { | ||
__extends(Request, _super); | ||
function Request(requestOptions) { | ||
_super.call(this); | ||
// TODO: assert that url is present | ||
@@ -73,3 +81,2 @@ var url = requestOptions.url; | ||
this._body = requestOptions.body; | ||
this.contentType = this.detectContentType(); | ||
this.method = http_utils_1.normalizeMethodName(requestOptions.method); | ||
@@ -80,42 +87,30 @@ // TODO(jeffbcross): implement behavior | ||
this.headers = new headers_1.Headers(requestOptions.headers); | ||
this.contentType = this.detectContentType(); | ||
this.withCredentials = requestOptions.withCredentials; | ||
this.responseType = requestOptions.responseType; | ||
} | ||
/** | ||
* Returns the request's body as string, assuming that body exists. If body is undefined, return | ||
* empty | ||
* string. | ||
* Returns the content type enum based on header options. | ||
*/ | ||
Request.prototype.text = function () { return lang_1.isPresent(this._body) ? this._body.toString() : ''; }; | ||
/** | ||
* Returns the request's body as JSON string, assuming that body exists. If body is undefined, | ||
* return | ||
* empty | ||
* string. | ||
*/ | ||
Request.prototype.json = function () { return lang_1.isPresent(this._body) ? JSON.stringify(this._body) : ''; }; | ||
/** | ||
* Returns the request's body as array buffer, assuming that body exists. If body is undefined, | ||
* return | ||
* null. | ||
*/ | ||
Request.prototype.arrayBuffer = function () { | ||
if (this._body instanceof ArrayBuffer) | ||
return this._body; | ||
throw 'The request body isn\'t an array buffer'; | ||
Request.prototype.detectContentType = function () { | ||
switch (this.headers.get('content-type')) { | ||
case 'application/json': | ||
return enums_1.ContentType.JSON; | ||
case 'application/x-www-form-urlencoded': | ||
return enums_1.ContentType.FORM; | ||
case 'multipart/form-data': | ||
return enums_1.ContentType.FORM_DATA; | ||
case 'text/plain': | ||
case 'text/html': | ||
return enums_1.ContentType.TEXT; | ||
case 'application/octet-stream': | ||
return enums_1.ContentType.BLOB; | ||
default: | ||
return this.detectContentTypeFromBody(); | ||
} | ||
}; | ||
/** | ||
* Returns the request's body as blob, assuming that body exists. If body is undefined, return | ||
* null. | ||
*/ | ||
Request.prototype.blob = function () { | ||
if (this._body instanceof Blob) | ||
return this._body; | ||
if (this._body instanceof ArrayBuffer) | ||
return new Blob([this._body]); | ||
throw 'The request body isn\'t either a blob or an array buffer'; | ||
}; | ||
/** | ||
* Returns the content type of request's body based on its type. | ||
*/ | ||
Request.prototype.detectContentType = function () { | ||
Request.prototype.detectContentTypeFromBody = function () { | ||
if (this._body == null) { | ||
@@ -150,3 +145,3 @@ return enums_1.ContentType.NONE; | ||
case enums_1.ContentType.JSON: | ||
return this.json(); | ||
return this.text(); | ||
case enums_1.ContentType.FORM: | ||
@@ -167,3 +162,3 @@ return this.text(); | ||
return Request; | ||
}()); | ||
}(body_1.Body)); | ||
exports.Request = Request; | ||
@@ -170,0 +165,0 @@ var noop = function () { }; |
import { ResponseOptions } from './base_response_options'; | ||
import { Body } from './body'; | ||
import { ResponseType } from './enums'; | ||
@@ -24,3 +25,3 @@ import { Headers } from './headers'; | ||
*/ | ||
export declare class Response { | ||
export declare class Response extends Body { | ||
/** | ||
@@ -73,21 +74,4 @@ * One of "basic", "cors", "default", "error, or "opaque". | ||
headers: Headers; | ||
private _body; | ||
constructor(responseOptions: ResponseOptions); | ||
/** | ||
* Not yet implemented | ||
*/ | ||
blob(): any; | ||
/** | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
*/ | ||
json(): any; | ||
/** | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
*/ | ||
text(): string; | ||
/** | ||
* Not yet implemented | ||
*/ | ||
arrayBuffer(): any; | ||
toString(): string; | ||
} |
@@ -9,5 +9,8 @@ /** | ||
"use strict"; | ||
var exceptions_1 = require('../src/facade/exceptions'); | ||
var lang_1 = require('../src/facade/lang'); | ||
var http_utils_1 = require('./http_utils'); | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var body_1 = require('./body'); | ||
/** | ||
@@ -33,4 +36,6 @@ * Creates `Response` instances from provided values. | ||
*/ | ||
var Response = (function () { | ||
var Response = (function (_super) { | ||
__extends(Response, _super); | ||
function Response(responseOptions) { | ||
_super.call(this); | ||
this._body = responseOptions.body; | ||
@@ -44,31 +49,2 @@ this.status = responseOptions.status; | ||
} | ||
/** | ||
* Not yet implemented | ||
*/ | ||
// TODO: Blob return type | ||
Response.prototype.blob = function () { throw new exceptions_1.BaseException('"blob()" method not implemented on Response superclass'); }; | ||
/** | ||
* Attempts to return body as parsed `JSON` object, or raises an exception. | ||
*/ | ||
Response.prototype.json = function () { | ||
var jsonResponse; | ||
if (http_utils_1.isJsObject(this._body)) { | ||
jsonResponse = this._body; | ||
} | ||
else if (lang_1.isString(this._body)) { | ||
jsonResponse = lang_1.Json.parse(this._body); | ||
} | ||
return jsonResponse; | ||
}; | ||
/** | ||
* Returns the body as a string, presuming `toString()` can be called on the response body. | ||
*/ | ||
Response.prototype.text = function () { return this._body.toString(); }; | ||
/** | ||
* Not yet implemented | ||
*/ | ||
// TODO: ArrayBuffer return type | ||
Response.prototype.arrayBuffer = function () { | ||
throw new exceptions_1.BaseException('"arrayBuffer()" method not implemented on Response superclass'); | ||
}; | ||
Response.prototype.toString = function () { | ||
@@ -78,4 +54,4 @@ return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url; | ||
return Response; | ||
}()); | ||
}(body_1.Body)); | ||
exports.Response = Response; | ||
//# sourceMappingURL=static_response.js.map |
@@ -17,6 +17,5 @@ /** | ||
params.forEach(function (param) { | ||
var split = param.split('=', 2); | ||
var key = split[0]; | ||
var val = split[1]; | ||
var list = lang_1.isPresent(map.get(key)) ? map.get(key) : []; | ||
var 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) || []; | ||
list.push(val); | ||
@@ -95,3 +94,3 @@ map.set(key, list); | ||
URLSearchParams.prototype.clone = function () { | ||
var clone = new URLSearchParams(); | ||
var clone = new URLSearchParams('', this.queryEncoder); | ||
clone.appendAll(this); | ||
@@ -98,0 +97,0 @@ return clone; |
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
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
893189
179
12067