Fix a bug which caused 'docker push' to fail with 411-lenght-required in Go 1.0

This commit is contained in:
Solomon Hykes 2013-04-02 18:37:29 -07:00
parent 0e1781af26
commit a05af3ebf3
1 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,6 @@
package docker package docker
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/dotcloud/docker/auth" "github.com/dotcloud/docker/auth"
@ -33,7 +32,7 @@ func NewImgJson(src []byte) (*Image, error) {
func NewMultipleImgJson(src []byte) ([]*Image, error) { func NewMultipleImgJson(src []byte) ([]*Image, error) {
ret := []*Image{} ret := []*Image{}
dec := json.NewDecoder(bytes.NewReader(src)) dec := json.NewDecoder(strings.NewReader(string(src)))
for { for {
m := &Image{} m := &Image{}
if err := dec.Decode(m); err == io.EOF { if err := dec.Decode(m); err == io.EOF {
@ -227,7 +226,7 @@ func (graph *Graph) PushImage(stdout io.Writer, imgOrig *Image, authConfig *auth
fmt.Fprintf(stdout, "Pushing %s metadata\n", img.Id) fmt.Fprintf(stdout, "Pushing %s metadata\n", img.Id)
// FIXME: try json with UTF8 // FIXME: try json with UTF8
jsonData := bytes.NewReader(jsonRaw) jsonData := strings.NewReader(string(jsonRaw))
req, err := http.NewRequest("PUT", REGISTRY_ENDPOINT+"/images/"+img.Id+"/json", jsonData) req, err := http.NewRequest("PUT", REGISTRY_ENDPOINT+"/images/"+img.Id+"/json", jsonData)
if err != nil { if err != nil {
return err return err