Fully re-submit batch requests on 401

When a batch request received a 401, the request was re-run without
resetting the Body, causing the request to error and fall back to
individual processing. This just reruns the Batch() function.
This commit is contained in:
rubyist 2015-07-07 11:29:33 -04:00
parent f57eb5e7c0
commit 931d0fb48e

@ -200,16 +200,21 @@ func Batch(objects []*objectResource, operation string) ([]*objectResource, *Wra
tracerx.Printf("api: batch %d files", len(objects))
res, objs, wErr := doApiBatchRequest(req, creds)
if wErr != nil {
if res != nil {
switch res.StatusCode {
case 404, 410:
tracerx.Printf("api: batch not implemented: %d", res.StatusCode)
sendApiEvent(apiEventFail)
return nil, Error(newNotImplError())
}
if res == nil {
sendApiEvent(apiEventFail)
return nil, wErr
}
switch res.StatusCode {
case 401:
Config.SetPrivateAccess()
tracerx.Printf("api: batch not authorized, submitting with auth")
return Batch(objects, operation)
case 404, 410:
tracerx.Printf("api: batch not implemented: %d", res.StatusCode)
sendApiEvent(apiEventFail)
return nil, Error(newNotImplError())
}
sendApiEvent(apiEventFail)
return nil, wErr
}
LogTransfer("lfs.api.batch", res)
@ -446,11 +451,6 @@ func doApiBatchRequest(req *http.Request, creds Creds) (*http.Response, []*objec
via := make([]*http.Request, 0, 4)
res, wErr := doApiRequestWithRedirects(req, creds, via)
if res != nil && res.StatusCode == 401 {
Config.SetPrivateAccess()
res, wErr = doApiRequestWithRedirects(req, creds, via)
}
if wErr != nil {
return res, nil, wErr
}