aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/requests.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r--server/helpers/requests.ts8
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 @@
1import * as Promise from 'bluebird' 1import * as Promise from 'bluebird'
2import { createWriteStream } from 'fs' 2import { createWriteStream } from 'fs'
3import * as request from 'request' 3import * as request from 'request'
4import { ACTIVITY_PUB } from '../initializers'
5
6function 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
5function 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 })