From bb43b40f196ab89775fe45738095aee90244061a Mon Sep 17 00:00:00 2001 From: Char Date: Mon, 1 Sep 2025 10:42:21 +0800 Subject: [PATCH] http: add CheckRedirect field to Client for compatibility with oauth2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- http/client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/http/client.go b/http/client.go index 09296f3..be3e137 100644 --- a/http/client.go +++ b/http/client.go @@ -61,6 +61,22 @@ type Client struct { // If nil, DefaultTransport is used. Transport RoundTripper + // CheckRedirect specifies the policy for handling redirects. + // If CheckRedirect is not nil, the client calls it before + // following an HTTP redirect. The arguments req and via are + // the upcoming request and the requests made already, oldest + // first. If CheckRedirect returns an error, the Client's Get + // method returns both the previous Response (with its Body + // closed) and CheckRedirect's error (wrapped in a url.Error) + // instead of issuing the Request req. + // As a special case, if CheckRedirect returns ErrUseLastResponse, + // then the most recent response is returned with its body + // unclosed, along with a nil error. + // + // If CheckRedirect is nil, the Client uses its default policy, + // which is to stop after 10 consecutive requests. + CheckRedirect func(req *Request, via []*Request) error + // Jar specifies the cookie jar. // // The Jar is used to insert relevant cookies into every