diff options
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 4b1deeadc..ce185a2c0 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,8 +1,14 @@ | |||
1 | import * as Promise from 'bluebird' | 1 | import * as Promise from 'bluebird' |
2 | import { createWriteStream } from 'fs' | 2 | import { createWriteStream } from 'fs' |
3 | import * as request from 'request' | 3 | import * as request from 'request' |
4 | import { ACTIVITY_PUB } from '../initializers' | ||
5 | |||
6 | function doRequest (requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }) { | ||
7 | if (requestOptions.activityPub === true) { | ||
8 | if (!Array.isArray(requestOptions.headers)) requestOptions.headers = {} | ||
9 | requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER | ||
10 | } | ||
4 | 11 | ||
5 | function doRequest (requestOptions: request.CoreOptions & request.UriOptions) { | ||
6 | return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { | 12 | return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { |
7 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) | 13 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) |
8 | }) | 14 | }) |