@samitouri / QOSami-HFS / commits / 0ad57f63

fix: broken connections were logged as having downloaded the whole file

Massimo Melina committed Jan 8, 2024 at 23:46 UTC 0ad57f63380f89ff2c54ddb817804399510eeb53
2 files changed +1 -2
dev.md
-1
@@ -43,7 +43,6 @@ Additionally, you have the following folders:
43 - tests: automated tests with related resources
44
45 # Known problems
46 --
46 - vite's proxying server (but also CRA's) doesn't play nicely with SSE, leaving sockets open
47
48 # Guidelines
src/throttler.ts
+1 -1
@@ -81,7 +81,7 @@ export const throttler: Koa.Middleware = async (ctx, next) => {
81
82 if (downloadTotal) // preserve this info
83 ctx.response.length = downloadTotal
84 - ts.once('end', () => // in case of compressed response, we offer calculation of real size
84 + ts.once('close', () => // in case of compressed response, we offer calculation of real size
85 ctx.state.length = ts.getBytesSent() - offset)
86 }
87