Browse code

Add redirect and env proxy support to docker login

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/06/03 09:46:06
Showing 1 changed files
... ...
@@ -5,12 +5,13 @@ import (
5 5
 	"encoding/json"
6 6
 	"errors"
7 7
 	"fmt"
8
-	"github.com/dotcloud/docker/utils"
9 8
 	"io/ioutil"
10 9
 	"net/http"
11 10
 	"os"
12 11
 	"path"
13 12
 	"strings"
13
+
14
+	"github.com/dotcloud/docker/utils"
14 15
 )
15 16
 
16 17
 // Where we store the config file
... ...
@@ -152,10 +153,16 @@ func SaveConfig(configFile *ConfigFile) error {
152 152
 // try to register/login to the registry server
153 153
 func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, error) {
154 154
 	var (
155
-		status        string
156
-		reqBody       []byte
157
-		err           error
158
-		client        = &http.Client{}
155
+		status  string
156
+		reqBody []byte
157
+		err     error
158
+		client  = &http.Client{
159
+			Transport: &http.Transport{
160
+				DisableKeepAlives: true,
161
+				Proxy:             http.ProxyFromEnvironment,
162
+			},
163
+			CheckRedirect: AddRequiredHeadersToRedirectedRequests,
164
+		}
159 165
 		reqStatusCode = 0
160 166
 		serverAddress = authConfig.ServerAddress
161 167
 	)