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

fix(stark-core): refactor Http headers related API to prevent undefined and null header values to be added to Angular Http headers #881

Conversation

christophercr
Copy link
Collaborator

ISSUES CLOSED: #856

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #856

What is the new behavior?

The correlationId Http header is not added in case the correlation id is not defined (which is the case when the loggingFlushDisabled is true).

Does this PR introduce a breaking change?

[ ] Yes
[X] No

@coveralls
Copy link

coveralls commented Nov 23, 2018

Coverage Status

Coverage increased (+0.05%) to 93.567% when pulling c728f9c on christophercr:feature/fix-http-undefined-correlation-id into b84f8e5 on NationalBankBelgium:master.

@christophercr christophercr force-pushed the feature/fix-http-undefined-correlation-id branch from 5ea9acc to 2c1c826 Compare November 23, 2018 10:42
@christophercr christophercr changed the title fix(stark-core): don't add correlationId Http header if the correlation id is undefined (logging flush disabled) fix(stark-core): refactor Http headers related API to prevent undefined and null header values to be added to Angular Http headers Nov 23, 2018
if (typeof value !== "undefined") {
public setHeader(name: string, value: string | string[]): this {
// in Angular, a header value can only be string or string[], not null/undefined (https://github.com/angular/angular/issues/18743)
if (typeof value !== "undefined" && value !== null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we cannot set undefined or null as header value but we don't check the name itself.
What would happen if the name was undefined or null ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I'll fix this

@@ -358,7 +358,12 @@ export class StarkSessionServiceImpl implements StarkSessionService {
this._devAuthenticationHeaders = new Map<string, string>();
}

devAuthenticationHeaders.forEach((value: string, key: string) => this._devAuthenticationHeaders.set(key, value));
devAuthenticationHeaders.forEach((value: string, key: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we change this to (value: string | string[], key: string) => {?

Because you mention in the comment above that Angular supports both but it is not implemented in this case...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I'll fix this

…ion service to prevent undefined and null header values to be added to Angular Http headers.

ISSUES CLOSED: #856
@christophercr christophercr force-pushed the feature/fix-http-undefined-correlation-id branch from 2c1c826 to c728f9c Compare November 23, 2018 15:24
@SuperITMan SuperITMan merged commit 962e0fb into NationalBankBelgium:master Nov 23, 2018
@christophercr christophercr deleted the feature/fix-http-undefined-correlation-id branch November 26, 2018 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core: http - Error when performing a request with loggingFlushDisabled set to true
3 participants