繁体   English   中英

AngularJS-获取响应头

[英]AngularJS - get headers in response

我正在对具有XML文件的https服务执行$http.get请求,它需要headers('Content-length')知道它的大小。

这是我的代码:

$http({
    method : "GET",
    url : "https://url.com/xml_file.xml"
}).then(
  function sCallback(data, status, headers, config, statusText) { 

    console.log( headers('Content-Length') );

}, function eCallback(data, status, headers, config, statusText) {

    $log.warn(data, status, headers, config, statusText);

});

请求的结果是: "headers is not a function" 还有另一种方法吗?

  console.log( data.headers('Content-Length')); console.log( data.headers('Content-type')); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM