3 const replay = require('request-replay')
4 const request = require('request')
6 const constants = require('../initializers/constants')
7 const peertubeCrypto = require('./peertube-crypto')
14 function makeRetryRequest (params, callback) {
16 request(params, callback),
18 retries: constants.RETRY_REQUESTS,
21 errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ]
26 function makeSecureRequest (params, callback) {
27 const requestParams = {
28 url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path
31 // Add data with POST requst ?
32 if (params.method === 'POST') {
33 requestParams.json = {}
35 // Add signature if it is specified in the params
36 if (params.sign === true) {
37 const host = constants.CONFIG.WEBSERVER.HOST
39 requestParams.json.signature = {
41 signature: peertubeCrypto.sign(host)
45 // If there are data informations
47 requestParams.json.data = params.data
48 request.post(requestParams, callback)
51 request.post(requestParams, callback)
54 request.get(requestParams, callback)
58 // ---------------------------------------------------------------------------
60 module.exports = requests