mirror of https://github.com/perkeep/perkeep.git
Follow 303 redirects in Go upload client.
This commit is contained in:
parent
7f85b55928
commit
f3b9b66eb0
|
@ -133,9 +133,17 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, os.Error) {
|
|||
if !ok {
|
||||
return error("303 without a Location", nil)
|
||||
}
|
||||
log.Printf("other location: %s", otherLocation)
|
||||
// TODO
|
||||
log.Exitf("TODO: handle 303? or does the Go http client do it already? how to enforce only 200 and 303 if so?")
|
||||
relUrl, err := http.ParseURL(otherLocation)
|
||||
if err != nil {
|
||||
return error("303 Location URL parse error", err)
|
||||
}
|
||||
baseUrl, _ := http.ParseURL(uploadUrl)
|
||||
absUrl := baseUrl.Add(relUrl)
|
||||
otherLocation = absUrl.String()
|
||||
resp, _, err = http.Get(otherLocation)
|
||||
if err != nil {
|
||||
return error("error following 303 redirect after upload", err)
|
||||
}
|
||||
}
|
||||
|
||||
ures, err := jsonFromResponse(resp)
|
||||
|
|
Loading…
Reference in New Issue