Skip to content

Commit 6e50c9e

Browse files
neilalexanderneild
authored andcommitted
net/http: guarantee that the Transport dial functions are respected in 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]>
1 parent db05b12 commit 6e50c9e

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ Nathan Youngman <[email protected]>
10151015
Nathaniel Cook <[email protected]>
10161016
Naveen Kumar Sangi <[email protected]>
10171017
Neelesh Chandola <[email protected]>
1018+
Neil Alexander <[email protected]>
10181019
Neil Lyons <[email protected]>
10191020
Netflix, Inc.
10201021
Neuman Vong <[email protected]>

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,7 @@ Naveen Kumar Sangi <[email protected]>
19011901
Neeilan Selvalingam <[email protected]>
19021902
Neelesh Chandola <[email protected]>
19031903
Nehal J Wani <[email protected]>
1904+
Neil Alexander <[email protected]>
19041905
Neil Lyons <[email protected]>
19051906
Neuman Vong <[email protected]>
19061907
Neven Sajko <[email protected]>

0 commit comments

Comments
 (0)