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

Custom headers emptying the headers map #173

Open
Malex opened this issue Jul 10, 2019 · 1 comment
Open

Custom headers emptying the headers map #173

Malex opened this issue Jul 10, 2019 · 1 comment

Comments

@Malex
Copy link

Malex commented Jul 10, 2019

I need to use in my application a custom header in response to a getList (header is totalElements).
It is correctly set by the backend, but of course in restangular the headers map only cointained the "default allowed" ones. For that reason I added Access-Control-Exposed-Headers. It is correctly returned, as per the following response, but after this change restangular does not populate the headers map entries


Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:4200
Access-Control-Expose-Headers: total-elements
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Wed, 10 Jul 2019 09:22:29 GMT
ETag: W/"d94-6ITA2YnKbkbSYtyM0pSSIrU0koc"
Expires: -1
Pragma: no-cache
total-elements: 13
Transfer-Encoding: chunked
Vary: Origin, Accept-Encoding
X-Powered-By: Express
@Malex
Copy link
Author

Malex commented Jul 10, 2019

Turns out
(response.headers as any).lazyInit();
was needed at the start of the ResponseInterceptor.
Which kinda makes sense, being a lazy initializer, but I wonder why in the default case (if the Expose-Headers was not set) they were initialized by default.
This behavior I think should be documented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant