mirror of
https://github.com/tinygo-org/net.git
synced 2026-08-21 21:08:59 +00:00
add bare minimum DefaultTransport (#32)
* add bare minimum DefaultTransport Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com> * use transport if explicitly configured by client Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com> --------- Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
This commit is contained in:
@@ -410,6 +410,10 @@ func urlErrorOp(method string) string {
|
|||||||
// Any returned error will be of type *url.Error. The url.Error
|
// Any returned error will be of type *url.Error. The url.Error
|
||||||
// value's Timeout method will report true if the request timed out.
|
// value's Timeout method will report true if the request timed out.
|
||||||
func (c *Client) Do(req *Request) (*Response, error) {
|
func (c *Client) Do(req *Request) (*Response, error) {
|
||||||
|
if c.Transport != nil {
|
||||||
|
return c.Transport.RoundTrip(req)
|
||||||
|
}
|
||||||
|
|
||||||
return c.do(req)
|
return c.do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,3 +20,12 @@ type readTrackingBody struct {
|
|||||||
didRead bool
|
didRead bool
|
||||||
didClose bool
|
didClose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Transport struct{}
|
||||||
|
|
||||||
|
var DefaultTransport RoundTripper = &Transport{}
|
||||||
|
|
||||||
|
// roundTrip implements a RoundTripper over HTTP.
|
||||||
|
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
|
||||||
|
return roundTrip(req)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user