Upload() looks for http 200, not 202
This commit is contained in:
parent
1d9edbb8df
commit
d743ff4db2
@ -155,7 +155,7 @@ func Upload(oidPath, filename string, cb CopyCallback) *WrappedError {
|
||||
return wErr
|
||||
}
|
||||
|
||||
if res.StatusCode == 202 {
|
||||
if res.StatusCode == 200 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -168,6 +168,7 @@ func Upload(oidPath, filename string, cb CopyCallback) *WrappedError {
|
||||
req.Header.Set("Content-Type", "application/octet-stream")
|
||||
}
|
||||
req.Header.Set("Content-Length", strconv.FormatInt(reqObj.Size, 10))
|
||||
req.ContentLength = reqObj.Size
|
||||
|
||||
reader := &CallbackReader{
|
||||
C: cb,
|
||||
|
@ -81,7 +81,7 @@ func TestExistingUpload(t *testing.T) {
|
||||
head := w.Header()
|
||||
head.Set("Content-Type", mediaType)
|
||||
head.Set("Content-Length", strconv.Itoa(len(by)))
|
||||
w.WriteHeader(202)
|
||||
w.WriteHeader(200)
|
||||
w.Write(by)
|
||||
})
|
||||
|
||||
@ -200,7 +200,7 @@ func TestSuccessfulUploadWithVerify(t *testing.T) {
|
||||
head := w.Header()
|
||||
head.Set("Content-Type", mediaType)
|
||||
head.Set("Content-Length", strconv.Itoa(len(by)))
|
||||
w.WriteHeader(200)
|
||||
w.WriteHeader(202)
|
||||
w.Write(by)
|
||||
})
|
||||
|
||||
@ -220,6 +220,14 @@ func TestSuccessfulUploadWithVerify(t *testing.T) {
|
||||
t.Error("Invalid Content-Type")
|
||||
}
|
||||
|
||||
if r.Header.Get("Content-Length") != "4" {
|
||||
t.Error("Invalid Content-Length")
|
||||
}
|
||||
|
||||
if r.Header.Get("Transfer-Encoding") != "" {
|
||||
t.Fatal("Transfer-Encoding is set")
|
||||
}
|
||||
|
||||
by, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@ -379,7 +387,7 @@ func TestSuccessfulUploadWithoutVerify(t *testing.T) {
|
||||
head := w.Header()
|
||||
head.Set("Content-Type", mediaType)
|
||||
head.Set("Content-Length", strconv.Itoa(len(by)))
|
||||
w.WriteHeader(200)
|
||||
w.WriteHeader(202)
|
||||
w.Write(by)
|
||||
})
|
||||
|
||||
@ -399,6 +407,14 @@ func TestSuccessfulUploadWithoutVerify(t *testing.T) {
|
||||
t.Error("Invalid Content-Type")
|
||||
}
|
||||
|
||||
if r.Header.Get("Content-Length") != "4" {
|
||||
t.Error("Invalid Content-Length")
|
||||
}
|
||||
|
||||
if r.Header.Get("Transfer-Encoding") != "" {
|
||||
t.Fatal("Transfer-Encoding is set")
|
||||
}
|
||||
|
||||
by, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@ -541,7 +557,7 @@ func TestUploadStorageError(t *testing.T) {
|
||||
head := w.Header()
|
||||
head.Set("Content-Type", mediaType)
|
||||
head.Set("Content-Length", strconv.Itoa(len(by)))
|
||||
w.WriteHeader(200)
|
||||
w.WriteHeader(202)
|
||||
w.Write(by)
|
||||
})
|
||||
|
||||
@ -646,7 +662,7 @@ func TestUploadVerifyError(t *testing.T) {
|
||||
head := w.Header()
|
||||
head.Set("Content-Type", mediaType)
|
||||
head.Set("Content-Length", strconv.Itoa(len(by)))
|
||||
w.WriteHeader(200)
|
||||
w.WriteHeader(202)
|
||||
w.Write(by)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user