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: allow reading body from non-2xx responses in net.request #21055

Merged
merged 5 commits into from
Nov 25, 2019
Merged

fix: allow reading body from non-2xx responses in net.request #21055

merged 5 commits into from
Nov 25, 2019

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented Nov 8, 2019

Description of Change

Context: https://cs.chromium.org/chromium/src/services/network/public/cpp/simple_url_loader.h?dr=C&g=0&l=262-276

SimpleURLLoader by default do not allow non-2xx http response as results, raises ERR_HTTP_RESPONSE_CODE_FAILURE and it makes attempt to read response body for those response not possible in net module's clientrequest.

This PR changes urlloader configuration to allow - this behavior matches to previous net module implementation, as well as browser native like fetch.

Checklist

Release Notes

Notes: Fixed net module request raises error when non-2xx response received.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Nov 8, 2019
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I'd love to get a test for this before we merge.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Nov 9, 2019
@miniak miniak requested a review from nornagon November 10, 2019 21:52
@nornagon nornagon changed the title fix: allow non-2xx repsponse results fix: allow reading body from non-2xx responses in net.request Nov 13, 2019
@nornagon
Copy link
Member

Hm, looks like the tests are consistently failing now. Perhaps this had some unintended consequences?

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

RC until CI is green

@kwonoj
Copy link
Contributor Author

kwonoj commented Nov 16, 2019

Relevant test case failures are corrected, but each time rebase to master some of tests are failing inconsistently, not sure if it's actually related tests & how to fix.

Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! @nornagon can you review the test code style.

return
}

expect(requestResponseEventEmitted).to.equal(true)
Copy link
Member

Choose a reason for hiding this comment

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

Calling expect() from an event / callback will result in the entire test process being aborted, instead of just failing the test. Please refactor similarly to https://github.com/electron/electron/pull/21265/files#diff-c31378831f4597a16ed943c2f7060323R566

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is mostly copy-paste from existing test cases like https://github.com/electron/electron/blob/master/spec-main/api-net-spec.ts#L337 fyi

Copy link
Member

Choose a reason for hiding this comment

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

yep, these changed with #21265

@MarshallOfSound MarshallOfSound merged commit ca61d2f into electron:master Nov 25, 2019
@release-clerk
Copy link

release-clerk bot commented Nov 25, 2019

Release Notes Persisted

Fixed net module request raises error when non-2xx response received.

@trop
Copy link
Contributor

trop bot commented Nov 25, 2019

I was unable to backport this PR to "7-1-x" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented Nov 25, 2019

I was unable to backport this PR to "8-x-y" cleanly;
you will need to perform this backport manually.

MarshallOfSound pushed a commit that referenced this pull request Nov 25, 2019
* fix(urlrequest): allow non-2xx repsponse results

- closes #21046

* test(net): add test cases to verify non-2xx body

* test(session): update spec to match clientrequest behavior

* test(net): update test cases to match clientrequest behavior

* spec: clean up async net spec
@trop
Copy link
Contributor

trop bot commented Nov 25, 2019

@MarshallOfSound has manually backported this PR to "8-x-y", please check out #21285

MarshallOfSound pushed a commit that referenced this pull request Nov 26, 2019
* fix(urlrequest): allow non-2xx repsponse results

- closes #21046

* test(net): add test cases to verify non-2xx body

* test(session): update spec to match clientrequest behavior

* test(net): update test cases to match clientrequest behavior

* spec: clean up async net spec
MarshallOfSound added a commit that referenced this pull request Nov 26, 2019
#21285)

* fix(urlrequest): allow non-2xx repsponse results

- closes #21046

* test(net): add test cases to verify non-2xx body

* test(session): update spec to match clientrequest behavior

* test(net): update test cases to match clientrequest behavior

* spec: clean up async net spec
trop bot pushed a commit that referenced this pull request Nov 26, 2019
* fix(urlrequest): allow non-2xx repsponse results

- closes #21046

* test(net): add test cases to verify non-2xx body

* test(session): update spec to match clientrequest behavior

* test(net): update test cases to match clientrequest behavior

* spec: clean up async net spec
MarshallOfSound pushed a commit that referenced this pull request Nov 27, 2019
#21295)

* fix: allow reading body from non-2xx responses in net.request (#21055)

* fix(urlrequest): allow non-2xx repsponse results

- closes #21046

* test(net): add test cases to verify non-2xx body

* test(session): update spec to match clientrequest behavior

* test(net): update test cases to match clientrequest behavior

* spec: clean up async net spec

* Update api-session-spec.js

* chore: fixup test as per original PR to master
@sofianguy sofianguy added this to Fixed in 8.0.0-beta.4 in 8.2.x Dec 9, 2019
@sofianguy sofianguy added this to Fixed in 7.1.3 in 7.2.x Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
7.2.x
Fixed in 7.1.3
8.2.x
Fixed in 8.0.0-beta.4
Development

Successfully merging this pull request may close these issues.

None yet

4 participants