]> Kevux Git Server - rit/commit
http: add support for HTTP 429 rate limit retries
authorVaidas Pilkauskas <vaidas.pilkauskas@shopify.com>
Tue, 17 Mar 2026 13:00:35 +0000 (13:00 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Mar 2026 16:14:19 +0000 (09:14 -0700)
commit640657ffd06999ec1ec3b1d030b7f5aac6b7f57b
tree2c64d3e66fb76d7125fc9552a9358880319ff906
parenta4fddb01c5bd0ecbd5e297ee571ad29ca62bf940
http: add support for HTTP 429 rate limit retries

Add retry logic for HTTP 429 (Too Many Requests) responses to handle
server-side rate limiting gracefully. When Git's HTTP client receives
a 429 response, it can now automatically retry the request after an
appropriate delay, respecting the server's rate limits.

The implementation supports the RFC-compliant Retry-After header in
both delay-seconds (integer) and HTTP-date (RFC 2822) formats. If a
past date is provided, Git retries immediately without waiting.

Retry behavior is controlled by three new configuration options
(http.maxRetries, http.retryAfter, and http.maxRetryTime) which are
documented in git-config(1).

The retry logic implements a fail-fast approach: if any delay
(whether from server header or configuration) exceeds maxRetryTime,
Git fails immediately with a clear error message rather than capping
the delay. This provides better visibility into rate limiting issues.

The implementation includes extensive test coverage for basic retry
behavior, Retry-After header formats (integer and HTTP-date),
configuration combinations, maxRetryTime limits, invalid header
handling, environment variable overrides, and edge cases.

Signed-off-by: Vaidas Pilkauskas <vaidas.pilkauskas@shopify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/http.adoc
git-curl-compat.h
http.c
http.h
remote-curl.c
t/lib-httpd.sh
t/lib-httpd/apache.conf
t/lib-httpd/http-429.sh [new file with mode: 0644]
t/meson.build
t/t5584-http-429-retry.sh [new file with mode: 0755]