fix: allow reading body from non-2xx responses in net.request (#21055) (#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
This commit is contained in:
trop[bot]
2019-11-26 17:32:56 -08:00
committed by Samuel Attard
parent 4cfa7be79d
commit 79b3fcb2ab
3 changed files with 66 additions and 7 deletions

View File

@@ -281,6 +281,7 @@ bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
network::ResourceRequest* request_ref = request_.get();
loader_ = network::SimpleURLLoader::Create(std::move(request_),
kTrafficAnnotation);
loader_->SetAllowHttpErrorResults(true);
loader_->SetOnResponseStartedCallback(base::Bind(
&URLRequestNS::OnResponseStarted, weak_factory_.GetWeakPtr()));
loader_->SetOnRedirectCallback(