1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Flush response headers always when proxy gets a response (#2229)

* flush response header always when proxy gets a response

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* force flush only when watch param exists

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-02-26 07:34:54 +02:00 committed by GitHub
parent 3acbdcfd60
commit 090a3c2bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,12 +120,18 @@ export class LensProxy {
protected createProxy(): httpProxy { protected createProxy(): httpProxy {
const proxy = httpProxy.createProxyServer(); const proxy = httpProxy.createProxyServer();
proxy.on("proxyRes", (proxyRes, req) => { proxy.on("proxyRes", (proxyRes, req, res) => {
const retryCounterId = this.getRequestId(req); const retryCounterId = this.getRequestId(req);
if (this.retryCounters.has(retryCounterId)) { if (this.retryCounters.has(retryCounterId)) {
this.retryCounters.delete(retryCounterId); this.retryCounters.delete(retryCounterId);
} }
if (!res.headersSent && req.url) {
const url = new URL(req.url, "http://localhost");
if (url.searchParams.has("watch")) res.flushHeaders();
}
}); });
proxy.on("error", (error, req, res, target) => { proxy.on("error", (error, req, res, target) => {