mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Follow redirections when sending PUT request in PushRepository
This commit is contained in:
parent
4cd9e4722c
commit
6e936c8fd3
1 changed files with 14 additions and 0 deletions
14
registry.go
14
registry.go
|
@ -466,6 +466,20 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
for res.StatusCode >= 300 && res.StatusCode < 400 {
|
||||||
|
Debugf("Redirected to %s\n", res.Header.Get("Location"))
|
||||||
|
req, err = http.NewRequest("PUT", res.Header.Get("Location"), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.SetBasicAuth(authConfig.Username, authConfig.Password)
|
||||||
|
res, err = client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
res.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
if res.StatusCode != 200 && res.StatusCode != 201 {
|
if res.StatusCode != 200 && res.StatusCode != 201 {
|
||||||
return fmt.Errorf("Error: Status %d trying to push repository %s", res.StatusCode, remote)
|
return fmt.Errorf("Error: Status %d trying to push repository %s", res.StatusCode, remote)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue