Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. function getProtocol (req) {
  2. var proto = req.connection.encrypted ? 'https' : 'http';
  3. // only do this if you trust the proxy
  4. proto = req.headers['x-forwarded-proto'] || proto;
  5. return proto.split(/\s*,\s*/)[0];
  6. }
  7.  
  8. new Promise((resolve, reject) => {
  9. let stream = request({
  10. uri: 'https://192.168.1.100:3000/config/properties.js',
  11. headers: {
  12. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  13. 'Accept-Encoding': 'gzip, deflate, br',
  14. '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',
  15. 'Cache-Control': 'max-age=0',
  16. 'Connection': 'keep-alive',
  17. 'Upgrade-Insecure-Requests': '1',
  18. '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'
  19. },
  20. gzip: true
  21. })
  22. .pipe(file)
  23. .on('finish', () => {
  24. resolve();
  25. console.log('The file finished downloading');
  26. })
  27. .on('error', (error) => {
  28. reject(error);
  29. })
  30. })
  31. .catch(error => {
  32. console.log('Something happened: ', error);
  33. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement