0

I want to read the response headers that came from accessing my website, so for example when I send a request to mywebsite.com it will return headers from aws CloudFront, I want to use one of these headers can someone advice? all I have been seeing is using the following and pass a url to make a new request, but I already have the response.

this.http.get<HttpResponse<Object>>(this.url, {observe: 'response'}).pipe(
         tap(resp => console.log('response', resp))
    );
Khaled Jamal
  • 628
  • 1
  • 6
  • 18

1 Answers1

0

In the Angular HttpResponse you can access the response headers by response.headers.get('theheader') and you can check if its there by using response.headers.has('theHeader'). Does not matter what kind of server implementation you call, as long as they follow http standards.

Abhishek
  • 1,742
  • 2
  • 14
  • 25
Jens Alenius
  • 1,931
  • 2
  • 16
  • 20
  • great, but how can I set the response? sorry im new to angular and programming – Khaled Jamal Aug 16 '19 at 15:08
  • You set the request. Not the response. Well maybe you might want too set the response if you would like to alter it before it reaches your inner controls and components. Do you want to do that? – Jens Alenius Aug 16 '19 at 18:20
  • actually I managed to do it using my backend, send the header to the java backend then using httpServlerRequest I managed to get it – Khaled Jamal Aug 16 '19 at 20:56