Skip to content

Commit

Permalink
client: Better handle http errors
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
  • Loading branch information
stgraber committed Jan 11, 2017
1 parent 6806e84 commit e4b3a28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ func (c *Client) PostImage(imageFile string, rootfsFile string, properties []str
}

req, err = http.NewRequest("POST", uri, progress)
if err != nil {
return "", err
}

req.Header.Set("Content-Type", w.FormDataContentType())
} else {
fImage, err = os.Open(imageFile)
Expand All @@ -1020,6 +1024,10 @@ func (c *Client) PostImage(imageFile string, rootfsFile string, properties []str
}

req, err = http.NewRequest("POST", uri, progress)
if err != nil {
return "", err
}

req.Header.Set("X-LXD-filename", filepath.Base(imageFile))
req.Header.Set("Content-Type", "application/octet-stream")
}
Expand Down

0 comments on commit e4b3a28

Please sign in to comment.