mirror of
https://github.com/tinygo-org/net.git
synced 2026-09-10 06:29:27 +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:
@@ -34,6 +34,12 @@ type readTrackingBody struct {
|
||||
// golang.org/x/net/http2 and google.golang.org/grpc. They are stored but, aside
|
||||
// from fetch, have no effect at runtime.
|
||||
type Transport struct {
|
||||
// Proxy specifies a function to return a proxy for a given Request.
|
||||
//
|
||||
// TINYGO: present for API compatibility; the netdev-backed transport dials
|
||||
// directly and does not consult it.
|
||||
Proxy func(*Request) (*url.URL, error)
|
||||
|
||||
// TLSClientConfig specifies the TLS configuration to use with tls.Client.
|
||||
TLSClientConfig *tls.Config
|
||||
|
||||
@@ -130,6 +136,14 @@ func ProxyFromEnvironment(req *Request) (*url.URL, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ProxyURL returns a proxy function (for use in a Transport) that always returns
|
||||
// the same URL.
|
||||
func ProxyURL(fixedURL *url.URL) func(*Request) (*url.URL, error) {
|
||||
return func(*Request) (*url.URL, error) {
|
||||
return fixedURL, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ErrSkipAltProtocol is a sentinel error value defined by Transport.RegisterProtocol.
|
||||
var ErrSkipAltProtocol = errors.New("net/http: skip alternate protocol")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user