Skip to content

Instantly share code, notes, and snippets.

@gabrielmiller
Last active January 4, 2016 06:18
Show Gist options
  • Save gabrielmiller/8580611 to your computer and use it in GitHub Desktop.
Save gabrielmiller/8580611 to your computer and use it in GitHub Desktop.
$http({
method: 'POST',
url: 'http://localhost:8000',
data: parameters
})
.success(function(data, status, headers, config){
var Headers = headers();
console.log(Headers);
})
.error(function(data, status, headers, config){
// Handle errors
});
/*
Output in console is as follows:
Object {content-type: "application/json; charset=utf-8"}
Output when curling the same endpoint is as follows:
$curl -kv http://localhost:8000
* Adding handle: conn: 0x7feaab80a600
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7feaab80a600) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8000 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE
< Access-Control-Allow-Headers: Content-Type
< Content-Type: application/json; charset=utf-8
< Content-Length: 14818
< ETag: "1946579797"
< Date: Thu, 23 Jan 2014 15:13:31 GMT
< Connection: keep-alive
Why does the angular response headers object not contain Date, ETag, Content-Length, etc?
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment