-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: guarantee that the Transport dial functions are respected in js/wasm #46923
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
net/http: guarantee that the Transport dial functions are respected in js/wasm #46923
Conversation
…ext, Dial and DialTLS functions in http.Transport are respected, even under JS/WASM There aren't any particular assumptions that state that the net.Conn has to be an actual socket, but instead might be a kind of virtual network or connection handler. The current API shape tries to use the Fetch API for everything, even when we've tried to tell the Transport not to.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
This PR (HEAD: 76ce48b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
This PR (HEAD: 01b6836) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 911ba26) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
Message from Damien Neil: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Neil Alexander: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
This PR (HEAD: 23ee196) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
Message from Neil Alexander: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Damien Neil: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
This PR (HEAD: 0ac1456) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
Message from Neil Alexander: Patch Set 5: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Damien Neil: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
This PR (HEAD: 948a0ed) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/330852 to see it. Tip: You can toggle comments from me using the |
Message from Neil Alexander: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Damien Neil: Patch Set 6: Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Damien Neil: Patch Set 6: Run-TryBot+1 Trust+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Go Bot: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Go Bot: Patch Set 6: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Carlos Amedee: Patch Set 6: Trust+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
Message from Richard Musiol: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/330852. |
…n js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed GitHub-Pull-Request: #46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <[email protected]> Trust: Damien Neil <[email protected]> Trust: Carlos Amedee <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]>
This PR is being closed because golang.org/cl/330852 has been merged. |
This PR adds a note into the Go 1.18 changelog for CL330852 / golang#46923.
This PR adds a note into the Go 1.18 changelog for CL 330852. Updates #46923. Change-Id: I99150e9275ce23fcf3697d6a22ac216818223c74 GitHub-Last-Rev: b2772ce GitHub-Pull-Request: #49258 Reviewed-on: https://go-review.googlesource.com/c/go/+/360297 Trust: Roland Shoemaker <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
…n js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <[email protected]> Trust: Damien Neil <[email protected]> Trust: Carlos Amedee <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]>
…n js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <[email protected]> Trust: Damien Neil <[email protected]> Trust: Carlos Amedee <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]>
…n js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <[email protected]> Trust: Damien Neil <[email protected]> Trust: Carlos Amedee <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]>
…n js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <[email protected]> Trust: Damien Neil <[email protected]> Trust: Carlos Amedee <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]>
The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package).
This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract.
This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified.
Fixes #27495