diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/requests.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index e8d77b15b..eb8a12868 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import * as Promise from 'bluebird' | 1 | import * as Bluebird 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' | 4 | import { ACTIVITY_PUB } from '../initializers' |
5 | import Bluebird = require('bluebird') | ||
6 | 5 | ||
7 | function doRequest ( | 6 | function doRequest ( |
8 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } | 7 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } |
@@ -12,13 +11,13 @@ function doRequest ( | |||
12 | requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER | 11 | requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER |
13 | } | 12 | } |
14 | 13 | ||
15 | return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { | 14 | return new Bluebird<{ response: request.RequestResponse, body: any }>((res, rej) => { |
16 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) | 15 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) |
17 | }) | 16 | }) |
18 | } | 17 | } |
19 | 18 | ||
20 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { | 19 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { |
21 | return new Promise<request.RequestResponse>((res, rej) => { | 20 | return new Bluebird<request.RequestResponse>((res, rej) => { |
22 | request(requestOptions) | 21 | request(requestOptions) |
23 | .on('response', response => res(response as request.RequestResponse)) | 22 | .on('response', response => res(response as request.RequestResponse)) |
24 | .on('error', err => rej(err)) | 23 | .on('error', err => rej(err)) |