Rewrite HTTP method for stream requests in GotRequester (#1602)

This prevents encountering HTTP 405 (Method not allowed) for API requests using streaming responses like Job Artifact downloads.
This commit is contained in:
Clemens Lieb 2021-03-13 03:27:24 +01:00 committed by GitHub
parent b2fe87af7e
commit a811e14d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,11 @@ export async function handler(endpoint: string, options: Record<string, unknown>
for (let i = 0; i < maxRetries; i += 1) {
const waitTime = 2 ** i * 0.1;
try {
if (options.method === 'stream') return Got(endpoint, options);
if (options.method === 'stream') {
options.method = 'get';
options.isStream = true;
return Got(endpoint, options);
}
response = await Got(endpoint, options); // eslint-disable-line
break;
} catch (e) {