mirror of https://github.com/keeweb/keeweb.git
fix #1478: fixed proxy issues with storage providers
This commit is contained in:
parent
2abdf3693c
commit
d140427c94
|
@ -138,8 +138,7 @@ class StorageBase {
|
|||
}
|
||||
|
||||
_httpRequestLauncher(config, onLoad) {
|
||||
Launcher.resolveProxy(config.url, proxy => {
|
||||
const https = Launcher.req('https');
|
||||
const net = Launcher.remReq('electron').net;
|
||||
|
||||
const opts = Launcher.req('url').parse(config.url);
|
||||
|
||||
|
@ -157,22 +156,20 @@ class StorageBase {
|
|||
} else {
|
||||
data = Buffer.from(config.data);
|
||||
}
|
||||
opts.headers['Content-Length'] = data.byteLength;
|
||||
// Electron's API doesn't like that, while node.js needs it
|
||||
// opts.headers['Content-Length'] = data.byteLength;
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
opts.headers.Host = opts.host;
|
||||
opts.host = proxy.host;
|
||||
opts.port = proxy.port;
|
||||
opts.path = config.url;
|
||||
}
|
||||
const req = net.request(opts);
|
||||
|
||||
const req = https.request(opts);
|
||||
let closed = false;
|
||||
req.on('close', () => {
|
||||
closed = true;
|
||||
});
|
||||
|
||||
req.on('response', res => {
|
||||
const chunks = [];
|
||||
res.on('data', chunk => chunks.push(chunk));
|
||||
res.on('end', () => {
|
||||
const onClose = () => {
|
||||
this.logger.debug(
|
||||
'HTTP response',
|
||||
opts.method,
|
||||
|
@ -199,7 +196,16 @@ class StorageBase {
|
|||
response,
|
||||
getResponseHeader: name => res.headers[name.toLowerCase()]
|
||||
});
|
||||
};
|
||||
res.on('data', chunk => {
|
||||
chunks.push(chunk);
|
||||
if (closed && !res.readable) {
|
||||
// sometimes 'close' event arrives faster in Electron
|
||||
onClose();
|
||||
}
|
||||
});
|
||||
// in Electron it's not res.on('end'), like in node.js, which is a bit weird
|
||||
req.on('close', onClose);
|
||||
});
|
||||
req.on('error', e => {
|
||||
this.logger.error('HTTP error', opts.method, config.url, e);
|
||||
|
@ -213,7 +219,6 @@ class StorageBase {
|
|||
req.write(data);
|
||||
}
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
_openPopup(url, title, width, height, extras) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
Release notes
|
||||
-------------
|
||||
##### v1.14.1 (WIP)
|
||||
`-` fix #1478: fixed proxy issues with storage providers
|
||||
|
||||
##### v1.14.0 (2020-04-18)
|
||||
`+` using OAuth authorization code grant for all storage providers
|
||||
`-` fixed a number of vulnerabilities in opening untrusted kdbx files
|
||||
|
|
Loading…
Reference in New Issue