本文整理汇总了TypeScript中angular2/http.Http.head方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Http.head方法的具体用法?TypeScript Http.head怎么用?TypeScript Http.head使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/http.Http
的用法示例。
在下文中一共展示了Http.head方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createRequest
private createRequest(type: string,data ?: Object) : Observable<any> {
let _url : string = this.buildUrl(data);
let _request : Observable<any>
let stringParam : string = '';
let _jsonBuild : any = {}
if(_url.split('?')[1] && _url.split('?')[1].length) {
(_url.split('?')[1].split('&')).forEach( _paramPart => {
_jsonBuild[_paramPart.split('=')[0]] = _paramPart.split('=')[1];
});
stringParam = JSON.stringify(_jsonBuild);
}
switch (type) {
case "post":
_request = this._http.post(_url.split('?')[0], stringParam);
break;
case "patch":
_request = this._http.patch(_url.split('?')[0], stringParam);
break;
case "put":
_request = this._http.put(_url.split('?')[0], stringParam);
break;
case "delete":
_request = this._http.delete(_url);
break;
case "head":
_request = this._http.head(_url);
break;
default:
_request = this._http.get(_url);
break;
}
this._request = _request.map((response: Response) => response.json());
return this._request;
}
示例2: initToken
initToken() {
console.log('initializing token');
this.http.head(this.headUrl)
.subscribe(
data=> {
console.log(data.headers.keys());
this.headerName = data.headers.get('X-CSRF-HEADER');
this.headerValue = data.headers.get('X-CSRF-TOKEN');
console.log("Header name: " + this.headerName + " headerValue: " + this.headerValue);
}
);
}
示例3: head
head(url: string, options?: RequestOptionsArgs): Observable<Response> {
url = this.buildUrl(url);
options = this.prepareOptions(options);
return this._http.head(url, options);
}
示例4: head
head(url:string, options?:RequestOptionsArgs):Observable<Response> {
return this.http.head(url, mergeAuthToken(options));
}
示例5: head
protected head(route: string, obj : any) {
return this._http.head(this._serviceBaseRouteName + route, obj);
}