Skip to content

Commit bb43b40

Browse files
cxjavadeadprogram
authored andcommitted
http: add CheckRedirect field to Client for compatibility with oauth2
This change introduces a CheckRedirect field to the http.Client struct in TinyGo, mirroring the behavior of Go's standard library http.Client. The purpose of this addition is to resolve build errors in projects that rely on packages (such as golang.org/x/oauth2) expecting the Client to have a CheckRedirect field. The field provides no functional change within TinyGo’s HTTP client at this time — it is only included for API compatibility and compilation success. There is no effect on runtime behavior unless explicitly used by downstream code.
1 parent 983d88d commit bb43b40

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

http/client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ type Client struct {
6161
// If nil, DefaultTransport is used.
6262
Transport RoundTripper
6363

64+
// CheckRedirect specifies the policy for handling redirects.
65+
// If CheckRedirect is not nil, the client calls it before
66+
// following an HTTP redirect. The arguments req and via are
67+
// the upcoming request and the requests made already, oldest
68+
// first. If CheckRedirect returns an error, the Client's Get
69+
// method returns both the previous Response (with its Body
70+
// closed) and CheckRedirect's error (wrapped in a url.Error)
71+
// instead of issuing the Request req.
72+
// As a special case, if CheckRedirect returns ErrUseLastResponse,
73+
// then the most recent response is returned with its body
74+
// unclosed, along with a nil error.
75+
//
76+
// If CheckRedirect is nil, the Client uses its default policy,
77+
// which is to stop after 10 consecutive requests.
78+
CheckRedirect func(req *Request, via []*Request) error
79+
6480
// Jar specifies the cookie jar.
6581
//
6682
// The Jar is used to insert relevant cookies into every

0 commit comments

Comments
 (0)