mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Don't use a strings.Reader where a bytes.Reader will do.
There are several places where a []byte is converted to a string and then fed into strings.NewReader().
This commit is contained in:
parent
c9a13147fe
commit
7830cf9166
2 changed files with 5 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -111,7 +112,7 @@ func Login(authConfig *AuthConfig) (string, error) {
|
||||||
return "", errors.New(errMsg)
|
return "", errors.New(errMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
b := strings.NewReader(string(jsonBody))
|
b := bytes.NewReader(jsonBody)
|
||||||
req1, err := http.Post(REGISTRY_SERVER+"/v1/users", "application/json; charset=utf-8", b)
|
req1, err := http.Post(REGISTRY_SERVER+"/v1/users", "application/json; charset=utf-8", b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = fmt.Sprintf("Server Error: %s", err)
|
errMsg = fmt.Sprintf("Server Error: %s", err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/auth"
|
"github.com/dotcloud/docker/auth"
|
||||||
|
@ -32,7 +33,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(strings.NewReader(string(src)))
|
dec := json.NewDecoder(bytes.NewReader(src))
|
||||||
for {
|
for {
|
||||||
m := &Image{}
|
m := &Image{}
|
||||||
if err := dec.Decode(m); err == io.EOF {
|
if err := dec.Decode(m); err == io.EOF {
|
||||||
|
@ -226,7 +227,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 := strings.NewReader(string(jsonRaw))
|
jsonData := bytes.NewReader(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
|
||||||
|
|
Loading…
Reference in a new issue