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(common): add right ContentType for boolean values with HttpClient request body(#38924) #41885
Conversation
189005f
to
97f144d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this shouldn't be a breaking change, but I wonder if it would actually break some people who have relied on booleans being marked as text...
f76484a
to
d1bee36
Compare
packages/common/http/src/request.ts
Outdated
@@ -324,7 +324,7 @@ export class HttpRequest<T> { | |||
} | |||
// Arrays, objects, and numbers will be encoded as JSON. | |||
if (typeof this.body === 'object' || typeof this.body === 'number' || | |||
Array.isArray(this.body)) { | |||
typeof this.body === 'boolean' || Array.isArray(this.body)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.isArray
is redundant because this.body
is an object in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S.: Update the comment in line 325
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alfaproject - I have updated the review comments, Please check.
… request body(angular#38924) currently a boolean as body is seen as text/plain, where is should be seen as application/json, since it is valid JSON, like numbers.
d1bee36
to
1cb2bdb
Compare
@petebacondarwin FYI presubmits are successful for the changes in this PR. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
We are adding application/json as ContentType for boolean as the body, currently it is seen as text/plain, where it should be seen as application/json, since it is valid JSON, like numbers.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
currently a boolean as the body is seen as text/plain, where it should be seen as application/json, since it is valid JSON, like numbers.
Issue Number: #38924
What is the new behavior?
currently a boolean as the body is seen as text/plain, where it should be seen as application/json, since it is valid JSON, like numbers.
Does this PR introduce a breaking change?
Other information