-1

[Completely rewritten to get to the heart of the issue]

I am using Angular6. The HttpClient communicates with a server application. I need to know how to read the headers on the response when utilizing HttpClient with the post and get methods.

//Psuedocode
constructor( private http : HttpClient ){
    ...
    let stream = http.post( url, data, options );
    stream.subscribe( ( response : any ){
        //here the response is stripped of headers
        //it is the body of the response decoded as a JSON object.
        //how do I read the response headers?
    } );
}
Jared Clemence
  • 1,062
  • 11
  • 26
  • Are you using both cookies AND JWTs? Generally speaking those two are not used together. Based on your issue description I'm assuming that your back-end is used as an API (which is generally stateless). First, are you using any frameworks on the back-end? If so, please list the technologies. I've successfully implemented a stateless API using SF 3.x on the BE with LDAP authentication and Angular FE using JWTs and never needed any cookies so I am intrigued by what you're trying to accomplish and how you're going about it. Thanks! – vpassapera Jun 18 '18 at 23:07
  • Sharing a sample of code would help. – Ulrich Dohou Jun 19 '18 at 07:21
  • The backend is a custom PHP application. The token system is customized also. Everything has been build from scratch based on employer specifications. Unfortunately, I am not permitted to share code snippets from this code base, because my boss things that the code is "special". – Jared Clemence Jun 21 '18 at 17:02
  • The front end is using Angular6. I can manually set the session cookie header in the requests if I can find a way to view the raw data packet in Angular6. This question is more about how to read the response headers in Angular6. – Jared Clemence Jun 21 '18 at 17:03

1 Answers1

0

The answer is found here: Angular Documentation - HttpClient - "Reading the Full Response"

To receive the full response the option must contain the following attribute and value:

let option = {
    ...
    observe: 'response',
    ...
}

This will modify the subscriber function call to pass in a HttpResponse object.

Jared Clemence
  • 1,062
  • 11
  • 26