Commit 33b16352 authored by Matt Bell's avatar Matt Bell Committed by Brian Tiger Chow

commands/http: Fixed client panic when sending a Request with nil 'Files'

parent fd9e4610
......@@ -48,14 +48,21 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
}
var fileReader *MultiFileReader
var reader io.Reader
if req.Files() != nil {
fileReader = NewMultiFileReader(req.Files(), true)
reader = fileReader
} else {
// if we have no file data, use an empty Reader
// (http.NewRequest panics when a nil Reader is used)
reader = strings.NewReader("")
}
path := strings.Join(req.Path(), "/")
url := fmt.Sprintf(ApiUrlFormat, c.serverAddress, ApiPath, path, query)
httpReq, err := http.NewRequest("POST", url, fileReader)
httpReq, err := http.NewRequest("POST", url, reader)
if err != nil {
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment