Add 429 retry batch scenario to lfstest
While the storage endpoint within lfstest-gitserver was already able to simulate a 429 "retry-after" scenario, the same support for the LFS batch API endpoint was missing. This commit adds this support in a similar manner to- and re-using the "checkRateLimit" function from the storage endpoint handler.
This commit is contained in:
parent
7266ee06be
commit
7410062329
@ -409,6 +409,17 @@ func lfsBatchHandler(w http.ResponseWriter, r *http.Request, id, repo string) {
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasSuffix(repo, "batch-retry-later") {
|
||||
if timeLeft, isWaiting := checkRateLimit("batch", "", repo, ""); isWaiting {
|
||||
w.Header().Set("Retry-After", strconv.Itoa(timeLeft))
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
|
||||
w.Write([]byte("rate limit reached"))
|
||||
fmt.Println("Setting header to: ", strconv.Itoa(timeLeft))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
res := []lfsObject{}
|
||||
testingChunked := testingChunkedTransferEncoding(r)
|
||||
testingTus := testingTusUploadInBatchReq(r)
|
||||
|
Loading…
Reference in New Issue
Block a user