Skip to content

Some fixes for common bugs in HttpClient#19958

Closed
alxhub wants to merge 4 commits intoangular:masterfrom
alxhub:http-fixes
Closed

Some fixes for common bugs in HttpClient#19958
alxhub wants to merge 4 commits intoangular:masterfrom
alxhub:http-fixes

Conversation

@alxhub
Copy link
Copy Markdown
Member

@alxhub alxhub commented Oct 26, 2017

No description provided.

@mary-poppins
Copy link
Copy Markdown

You can preview 62c7b98 at https://pr19958-62c7b98.ngbuilds.io/.

Copy link
Copy Markdown
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

The 4th commit also closes PR #19917 btw.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unused?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it is worth preserving the XSSI_PREFIX in this case 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, done in a new commit.

@mary-poppins
Copy link
Copy Markdown

You can preview 45006a5 at https://pr19958-45006a5.ngbuilds.io/.

@gkalpak gkalpak added area: common/http Issues related to HTTP and HTTP Client action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews PR target: TBD labels Oct 31, 2017
Copy link
Copy Markdown
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

The 4th commit has incorrect scope (service-worker instead of common).

@alxhub alxhub force-pushed the http-fixes branch 2 times, most recently from 9b5c135 to 4fa1792 Compare November 2, 2017 20:08
@mary-poppins
Copy link
Copy Markdown

You can preview 4fa1792 at https://pr19958-4fa1792.ngbuilds.io/.

@quanterion
Copy link
Copy Markdown

When is it going to be merged? Without those fixes it's impossible to use most HTTP DELETE requests that returns empty body

@Maximaximum
Copy link
Copy Markdown

Hopefully this PR will get released as soon as possible, because the empty body parse issue is a real show stopper.

@dinerotah
Copy link
Copy Markdown

dinerotah commented Nov 16, 2017

When this fix will be released ???
I spent too much time to migrate to the new HttpClient, it will be a frustration to downgrade.................

@valkoun
Copy link
Copy Markdown

valkoun commented Nov 16, 2017

FYI, in the meantime you can choose one of 3 options to workaround this:

  1. Make sure responses always return a response body with 200 responses, or
  2. Make each response with no response body return a 204 No Content code, or
  3. Set responseType: 'text' for each http method call:
return this.http.post('api/groups', group, {
      responseType: 'text',
});

@Maximaximum
Copy link
Copy Markdown

@valkoun yeah, thanks, but it's a whole lot of stupid error-prone work, so I hope this fix will get into release ASAP

@dinerotah
Copy link
Copy Markdown

dinerotah commented Nov 20, 2017

Meanwhile I fixed the problem on the server side returning http status 204 for all void service method and so no more parsing error.

@realshadow
Copy link
Copy Markdown

Will this also get merged back to 4.4.6 or 7?

@sougiovn
Copy link
Copy Markdown

When will it be released?

@vinayakpatil
Copy link
Copy Markdown

@alxhub Will this be merged anytime soon?

@alxhub
Copy link
Copy Markdown
Member Author

alxhub commented Nov 25, 2017 via email

Previously, HttpClient used the overly clever test "body || null"
to determine when a body parameter was provided. This breaks when
the valid bodies '0' or 'false' are provided.

This change tests directly against 'undefined' to detect the presence
of the body parameter, and thus correctly allows falsy values through.

Fixes angular#19825.
Fixes angular#19195.
An invalid "if" condition is always true, and is thus useless. This
change removes it. No behavior changes.

Fixes angular#19223.
Previously, XhrBackend would call JSON.parse('') if the response body was
empty (a 200 status code with content-length 0). This changes the XhrBackend
to attempt the JSON parse only if the response body is non-empty. Otherwise,
the body is left as null.

Fixes angular#18680.
Fixes angular#19413.
Fixes angular#19502.
Fixes angular#19555.
This changes XhrBackend to not strip the XSSI prefix from error text
if such a prefix is present but the remaining body does not parse as
JSON.
@mary-poppins
Copy link
Copy Markdown

You can preview 4a4cb9f at https://pr19958-4a4cb9f.ngbuilds.io/.

@alxhub alxhub added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews PR target: TBD labels Nov 28, 2017
@mhevery mhevery closed this in 15a54df Nov 29, 2017
mhevery pushed a commit that referenced this pull request Nov 29, 2017
An invalid "if" condition is always true, and is thus useless. This
change removes it. No behavior changes.

Fixes #19223.

PR Close #19958
mhevery pushed a commit that referenced this pull request Nov 29, 2017
…ent (#19958)

Previously, XhrBackend would call JSON.parse('') if the response body was
empty (a 200 status code with content-length 0). This changes the XhrBackend
to attempt the JSON parse only if the response body is non-empty. Otherwise,
the body is left as null.

Fixes #18680.
Fixes #19413.
Fixes #19502.
Fixes #19555.

PR Close #19958
mhevery pushed a commit that referenced this pull request Nov 29, 2017
This changes XhrBackend to not strip the XSSI prefix from error text
if such a prefix is present but the remaining body does not parse as
JSON.

PR Close #19958
@hspier
Copy link
Copy Markdown

hspier commented Nov 29, 2017

Any chance we can get a 4.4.7 release with this fix soon?

mhevery pushed a commit that referenced this pull request Nov 29, 2017
Previously, HttpClient used the overly clever test "body || null"
to determine when a body parameter was provided. This breaks when
the valid bodies '0' or 'false' are provided.

This change tests directly against 'undefined' to detect the presence
of the body parameter, and thus correctly allows falsy values through.

Fixes #19825.
Fixes #19195.

PR Close #19958
mhevery pushed a commit that referenced this pull request Nov 29, 2017
An invalid "if" condition is always true, and is thus useless. This
change removes it. No behavior changes.

Fixes #19223.

PR Close #19958
mhevery pushed a commit that referenced this pull request Nov 29, 2017
…ent (#19958)

Previously, XhrBackend would call JSON.parse('') if the response body was
empty (a 200 status code with content-length 0). This changes the XhrBackend
to attempt the JSON parse only if the response body is non-empty. Otherwise,
the body is left as null.

Fixes #18680.
Fixes #19413.
Fixes #19502.
Fixes #19555.

PR Close #19958
mhevery pushed a commit that referenced this pull request Nov 29, 2017
This changes XhrBackend to not strip the XSSI prefix from error text
if such a prefix is present but the remaining body does not parse as
JSON.

PR Close #19958
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
Previously, HttpClient used the overly clever test "body || null"
to determine when a body parameter was provided. This breaks when
the valid bodies '0' or 'false' are provided.

This change tests directly against 'undefined' to detect the presence
of the body parameter, and thus correctly allows falsy values through.

Fixes angular#19825.
Fixes angular#19195.

PR Close angular#19958
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
An invalid "if" condition is always true, and is thus useless. This
change removes it. No behavior changes.

Fixes angular#19223.

PR Close angular#19958
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
…ent (angular#19958)

Previously, XhrBackend would call JSON.parse('') if the response body was
empty (a 200 status code with content-length 0). This changes the XhrBackend
to attempt the JSON parse only if the response body is non-empty. Otherwise,
the body is left as null.

Fixes angular#18680.
Fixes angular#19413.
Fixes angular#19502.
Fixes angular#19555.

PR Close angular#19958
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
…#19958)

This changes XhrBackend to not strip the XSSI prefix from error text
if such a prefix is present but the remaining body does not parse as
JSON.

PR Close angular#19958
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: common/http Issues related to HTTP and HTTP Client cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.