http: port Go net/http timeout handling#67
Open
Darckfast wants to merge 1 commit into
Open
Conversation
This ports Go's timeout feature to TinyGo allowing it to handle timeouts when using `net/http` e.g. `c := http.Client{Timeout: 2 * time.Second}` will now return a timeout error if the request duration is longer than 2 seconds
By bringing the Go net/http client `.transport()` function, it also fixes the issue where only `roundTrip.go` was used, even when compiling to wasm, where `roundTrip_js.go` should be used
Fixes tinygo-org#58 and tinygo-org#66
146f177 to
ba49238
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ports Go's
net/httptimeout feature to TinyGo allowing it to handle timeouts when usingnet/httpe.g.^ this will now return a timeout error if the request duration is longer than 2 seconds
This port is pretty much 1:1 to Go own timeout implementation, i removed parts that TInyGo doesnt support (they are commented with
// TINYGO)By bringing the Go
net/httpclient.transport()function, it also fixes the issue where onlyroundTrip.gowas used by default, even when compiling to wasm, whereroundTrip_js.goshould be usedFixes #58
Fixes #66
I have wrote a wasm integration test , but i dont know how to go about it because it's inside
test/wasmin the main repo, do i just open a PR in the main repo with it? or you guys suggest something else?