2

I'm doing a $http.get request to a https service which has an XML file and it need the headers('Content-length') to know it size.

This's my code:

$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);

});

The result of the request is: "headers is not a function". Is there another way to get it?

Franco Manzur
  • 373
  • 1
  • 7
  • 19
  • 1
    Are you making this up? Why would you expect that to work?? – Amit Jul 04 '16 at 19:15
  • yes i'm doing it. I need that value to make a validation. This should work according to the documentation – Franco Manzur Jul 04 '16 at 19:25
  • Possible duplicate of [How can I access the Content-Length header from a cross domain Ajax request?](http://stackoverflow.com/questions/4850288/how-can-i-access-the-content-length-header-from-a-cross-domain-ajax-request) – Sherbrow Nov 07 '16 at 11:27

1 Answers1

-3

 console.log( data.headers('Content-Length'));
 console.log( data.headers('Content-type'));
Prianca
  • 484
  • 2
  • 8
  • Doesn't work for me, content-type esists, but content-length is absent. I see that server responds with content-length using postman. Have tried to modify transformResponse to contains single function (input) {return input;} – Rantiev Jan 16 '17 at 14:42
  • did you actually try this or just wrote the code to give the answer? – Foyzul Karim Jan 24 '18 at 01:35
  • @FoyzulKarim:YES – Prianca Feb 01 '18 at 12:04