mirror of
https://github.com/tinygo-org/net.git
synced 2026-09-09 22:19:26 +00:00
net/http: add ErrUseLastResponse, Client.CloseIdleConnections, Transport.Proxy and ProxyURL (#70)
* http: add ErrUseLastResponse and Client.CloseIdleConnections Both are API-compatibility fills. ErrUseLastResponse is a sentinel a CheckRedirect func returns to stop following redirects; nothing here has to act on it beyond existing. CloseIdleConnections delegates to the Transport when it has the method, which is what net/http does. Programs that reference either currently fail to compile against this package for want of a name, which is the whole cost.
This commit is contained in:
@@ -27,6 +27,11 @@ import (
|
||||
"golang.org/x/net/http/httpguts"
|
||||
)
|
||||
|
||||
// ErrUseLastResponse can be returned by Client.CheckRedirect to control how
|
||||
// redirects are processed: the most recent response is returned with its body
|
||||
// unclosed, and the error is nil. TINYGO: provided for API compatibility.
|
||||
var ErrUseLastResponse = errors.New("net/http: use last response")
|
||||
|
||||
// A Client is an HTTP client. Its zero value ([DefaultClient]) is a
|
||||
// usable client that uses [DefaultTransport].
|
||||
//
|
||||
@@ -585,3 +590,13 @@ func (c *Client) Head(url string) (resp *Response, err error) {
|
||||
}
|
||||
return c.Do(req)
|
||||
}
|
||||
|
||||
// CloseIdleConnections closes any connections on its Transport which were
|
||||
// previously connected from previous requests but are now idle. It delegates to
|
||||
// the Transport's CloseIdleConnections if it has one.
|
||||
func (c *Client) CloseIdleConnections() {
|
||||
type closeIdler interface{ CloseIdleConnections() }
|
||||
if tr, ok := c.Transport.(closeIdler); ok {
|
||||
tr.CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user