MCPcopy
hub / github.com/promptfoo/promptfoo / parseRetryAfter

Function parseRetryAfter

src/scheduler/headerParser.ts:122–136  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

120 * Exported for integration use.
121 */
122export function parseRetryAfter(value: string): number | null {
123 // Try as integer seconds (must be non-negative)
124 const seconds = parseInt(value, 10);
125 if (!isNaN(seconds) && seconds >= 0 && String(seconds) === value.trim()) {
126 return seconds * 1000;
127 }
128
129 // Try HTTP-date format
130 const httpDate = parseHttpDate(value);
131 if (httpDate !== null) {
132 return Math.max(0, httpDate - Date.now());
133 }
134
135 return null;
136}
137
138function parseFirstMatch(headers: Record<string, string>, names: string[]): number | undefined {
139 for (const name of names) {

Callers 4

computeRateLimitWaitMsFunction · 0.90
parseRateLimitHeadersFunction · 0.85

Calls 1

parseHttpDateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…