Add user agent to requests

This commit is contained in:
Chocobozzz 2020-02-18 15:36:38 +01:00
parent e886f1c937
commit 23f0d843c3
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 0 deletions

View File

@ -4,6 +4,9 @@ import * as request from 'request'
function doRequest <T> (
requestOptions: request.CoreOptions & request.UriOptions
): Bluebird<{ response: request.RequestResponse, body: T }> {
if (!(requestOptions.headers)) requestOptions.headers = {}
requestOptions.headers['User-Agent'] = 'PeerTube indexer'
return new Bluebird<{ response: request.RequestResponse, body: T }>((res, rej) => {
request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))
})