Parcourir la source

Merge pull request #37071 from mat007/custom-request

Extend client API with custom HTTP requests
Vincent Demeester il y a 7 ans
Parent
commit
d37f5c6bdf
2 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 5 0
      client/client.go
  2. 2 0
      client/interface.go

+ 5 - 0
client/client.go

@@ -356,6 +356,11 @@ func (cli *Client) DaemonHost() string {
 	return cli.host
 }
 
+// HTTPClient returns a copy of the HTTP client bound to the server
+func (cli *Client) HTTPClient() *http.Client {
+	return &*cli.client
+}
+
 // ParseHostURL parses a url string, validates the string is a host url, and
 // returns the parsed URL
 func ParseHostURL(host string) (*url.URL, error) {

+ 2 - 0
client/interface.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"io"
 	"net"
+	"net/http"
 	"time"
 
 	"github.com/docker/docker/api/types"
@@ -33,6 +34,7 @@ type CommonAPIClient interface {
 	VolumeAPIClient
 	ClientVersion() string
 	DaemonHost() string
+	HTTPClient() *http.Client
 	ServerVersion(ctx context.Context) (types.Version, error)
 	NegotiateAPIVersion(ctx context.Context)
 	NegotiateAPIVersionPing(types.Ping)