request: Send user-agent with request.

We now send the user-agent with the request.
Fixes #611.
This commit is contained in:
Akash Nimare
2018-12-18 18:16:18 +05:30
parent 61bbd1cf22
commit 48dd12b738

View File

@@ -12,6 +12,7 @@ const Logger = require('./logger-util');
const CertificateUtil = require(__dirname + '/certificate-util.js');
const ProxyUtil = require(__dirname + '/proxy-util.js');
const ConfigUtil = require(__dirname + '/config-util.js');
const SystemUtil = require(__dirname + '/../utils/system-util.js');
const logger = new Logger({
file: `domain-util.log`,
@@ -130,7 +131,8 @@ class DomainUtil {
url: domain + '/static/audio/zulip.ogg',
ca: (certificateLocation) ? certificateLocation : '',
proxy: proxyEnabled ? ProxyUtil.getProxy(domain) : '',
ecdhCurve: 'auto'
ecdhCurve: 'auto',
headers: { 'User-Agent': SystemUtil.getUserAgent() }
};
const serverConf = {
@@ -221,7 +223,8 @@ class DomainUtil {
url: domain + '/api/v1/server_settings',
ca: (certificateLocation) ? certificateLocation : '',
proxy: proxyEnabled ? ProxyUtil.getProxy(domain) : '',
ecdhCurve: 'auto'
ecdhCurve: 'auto',
headers: { 'User-Agent': SystemUtil.getUserAgent() }
};
return new Promise((resolve, reject) => {
request(serverSettingsOptions, (error, response) => {
@@ -266,7 +269,8 @@ class DomainUtil {
url,
ca: (certificateLocation) ? certificateLocation : '',
proxy: proxyEnabled ? ProxyUtil.getProxy(url) : '',
ecdhCurve: 'auto'
ecdhCurve: 'auto',
headers: { 'User-Agent': SystemUtil.getUserAgent() }
};
// The save will always succeed. If url is invalid, downgrade to default icon.