Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getProtocol (req) {
- var proto = req.connection.encrypted ? 'https' : 'http';
- // only do this if you trust the proxy
- proto = req.headers['x-forwarded-proto'] || proto;
- return proto.split(/\s*,\s*/)[0];
- }
- new Promise((resolve, reject) => {
- let stream = request({
- uri: 'https://192.168.1.100:3000/config/properties.js',
- headers: {
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Accept-Language': 'en-US,en;q=0.9,fr;q=0.8,ro;q=0.7,ru;q=0.6,la;q=0.5,pt;q=0.4,de;q=0.3',
- 'Cache-Control': 'max-age=0',
- 'Connection': 'keep-alive',
- 'Upgrade-Insecure-Requests': '1',
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
- },
- gzip: true
- })
- .pipe(file)
- .on('finish', () => {
- resolve();
- console.log('The file finished downloading');
- })
- .on('error', (error) => {
- reject(error);
- })
- })
- .catch(error => {
- console.log('Something happened: ', error);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement