headers.getAll() overload and get all sent headers (with browser defaults) inside HTTP_INTERCEPTORS
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
- Does not get all headers with .headers.getAll().
- Does not get all default headers sent when request.headers accessed from enum.sent
Expected behavior
- Get all headers with .headers.getAll(). Add overload for the same when arguments not provided. Proposal to add .getAll() method overload to get all headers at once.
- Get all default headers sent when request.headers accessed from enum.sent. Proposal to add all sent headers even browser default headers that can be all fetched with .getAll() overload.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-gitter-dygdrc?file=app%2Finterceptor.service.ts
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log('Request', request.headers.keys());
// Proposal to add .getAll() method overload to get all headers at once when no args are provided
return next
.handle(request).pipe(
tap((ev: HttpEvent<any>) => {
if (ev.type === HttpEventType.Sent) {
console.log('ReqAfterSent', request.headers);
// Proposal to add all sent headers even browser default headers that can be all fetched with .getAll() overload
}
})
);
}
What is the motivation / use case for changing the behavior?
Application use case when working just with headers.
Environment
Angular CLI: 6.1.4 Node: 10.7.0 OS: linux x64 Angular: 6.1.4 … animations, cli, common, compiler, compiler-cli, core, forms … http, language-service, platform-browser … platform-browser-dynamic, router
Package Version
@ angular-devkit/architect 0.7.4 @ angular-devkit/build-angular 0.7.4 @ angular-devkit/build-optimizer 0.7.4 @ angular-devkit/build-webpack 0.7.4 @ angular-devkit/core 0.7.4 @ angular-devkit/schematics 0.7.4 @ angular/cdk 6.4.6 @ angular/material 6.4.6 @ ngtools/webpack 6.1.4 @ schematics/angular 0.7.4 @ schematics/update 0.7.4 rxjs 6.2.2 typescript 2.7.2 webpack 4.9.2
Browser:
- [X ] Chrome (desktop) version XX
- [ X] Chrome (Android) version XX
- [ X] Chrome (iOS) version XX
- [X ] Firefox version XX
- [X ] Safari (desktop) version XX
- [X ] Safari (iOS) version XX
- [ X] IE version XX
- [ X] Edge version XX
For Tooling issues: na
Others: NA
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
This is an interesting idea - the
Sent
event could deliver information about the actually sent request, including headers if requested. I’ll think about this.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.