Visitar URL original
HttpClient post and get calls with options {observe:'response'} does not contain all response headers · Issue #44127 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20220131125114/https://github.com/angular/angular/issues/44127
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClient post and get calls with options {observe:'response'} does not contain all response headers #44127

Closed
activedecay opened this issue Nov 9, 2021 · 3 comments

Comments

@activedecay
Copy link

@activedecay activedecay commented Nov 9, 2021 •

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

No

Description

I don't know if this is a regression;

The documentation states that we can use the httpClient.get() function to create a stream, passing the options to read the full response using the 'observe' property.

I don't see most of the headers on the response stream. These were the only two headers that came through:

["content-length: 230","content-type: application/json"]

I expected these:

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 09 Nov 2021 22:56:24 GMT
Content-Type: application/json
Content-Length: 230
Connection: keep-alive
Location: https://covfefe/redfish/v1/SessionService/Sessions/11
X-Auth-Token: 4f3f82b2ffc9e1115e27525f3348815462d5aab7a9318f9d443772fd9247e8bc
Access-Control-Allow-Origin: http://localhost:4200
Vary: Origin
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Security-Policy: trusted-types angular; require-trusted-types-for 'script'
X-Xss-Protection: 1; mode=block

Please provide a link to a minimal reproduction of the bug

https://jsbin.com/kogexoraxu/edit?js

Please provide the exception or error you saw

I only saw a couple of headers; where are the rest of them? That's an error.

Please provide the environment you discovered this bug in

Angular CLI: 12.2.6
Node: 14.17.6
Package Manager: npm 7.23.0
OS: linux x64

Angular: 12.2.6
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.6
@angular-devkit/build-angular   12.2.6
@angular-devkit/core            12.2.6
@angular-devkit/schematics      12.2.6
@schematics/angular             12.2.6
rxjs                            6.6.7
typescript                      4.3.5

Anything else?

Neither a get nor a post method changes the behavior. Why can I not get the rest of the headers?

@activedecay
Copy link
Author

@activedecay activedecay commented Nov 9, 2021

https://stackoverflow.com/questions/52719212/how-to-read-http-response-header-in-angular

It's hilarious that this post on stack overflow is this old and nobody has answered it. Free reputation points here if you know the answer!

@activedecay activedecay changed the title HttpClient post with options {observe:'response'} does not contain all response headers HttpClient post and get calls with options {observe:'response'} does not contain all response headers Nov 10, 2021
@activedecay
Copy link
Author

@activedecay activedecay commented Nov 10, 2021 •

I think it's possibly related to the server not responding with the right headers to allow Angular to see it https://stackoverflow.com/a/52444472/823282

yep. it was a CORS issue. Access-Control-Expose-Headers should have been set first to inform the browser that it's OK to read the headers.

@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 11, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant