diff options
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index fc77ebd35..327610558 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -3,7 +3,7 @@ import got, { CancelableRequest, NormalizedOptions, Options as GotOptions, Reque | |||
3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' | 3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' | 6 | import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants' |
7 | import { pipelinePromise } from './core-utils' | 7 | import { pipelinePromise } from './core-utils' |
8 | import { processImage } from './image-utils' | 8 | import { processImage } from './image-utils' |
9 | import { logger, loggerTagsFactory } from './logger' | 9 | import { logger, loggerTagsFactory } from './logger' |
@@ -20,6 +20,7 @@ export interface PeerTubeRequestError extends Error { | |||
20 | } | 20 | } |
21 | 21 | ||
22 | type PeerTubeRequestOptions = { | 22 | type PeerTubeRequestOptions = { |
23 | timeout?: number | ||
23 | activityPub?: boolean | 24 | activityPub?: boolean |
24 | bodyKBLimit?: number // 1MB | 25 | bodyKBLimit?: number // 1MB |
25 | httpSignature?: { | 26 | httpSignature?: { |
@@ -129,7 +130,7 @@ async function doRequestAndSaveToFile ( | |||
129 | destPath: string, | 130 | destPath: string, |
130 | options: PeerTubeRequestOptions = {} | 131 | options: PeerTubeRequestOptions = {} |
131 | ) { | 132 | ) { |
132 | const gotOptions = buildGotOptions(options) | 133 | const gotOptions = buildGotOptions({ ...options, timeout: options.timeout ?? REQUEST_TIMEOUTS.FILE }) |
133 | 134 | ||
134 | const outFile = createWriteStream(destPath) | 135 | const outFile = createWriteStream(destPath) |
135 | 136 | ||
@@ -235,7 +236,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) { | |||
235 | return { | 236 | return { |
236 | method: options.method, | 237 | method: options.method, |
237 | dnsCache: true, | 238 | dnsCache: true, |
238 | timeout: REQUEST_TIMEOUT, | 239 | timeout: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT, |
239 | json: options.json, | 240 | json: options.json, |
240 | searchParams: options.searchParams, | 241 | searchParams: options.searchParams, |
241 | retry: 2, | 242 | retry: 2, |