feat: send bytes= query param on upload measurements#122
Conversation
There was a problem hiding this comment.
Summary
This PR makes the bytes=<size> query param unconditional on bandwidth measurement requests so that upload (POST /__up) requests now carry it too, matching download requests. This gives the server the upload-size signal it needs to enforce a byte ceiling on the upload body.
The single-line change in BandwidthEngine.ts:348 replaces the download-only short-circuit assignment (isDown && (qsParams.bytes = ...)) with an unconditional qsParams.bytes = ${numBytes}``.
Assessment
Correctness: Verified. The upload body is produced by genContent(numBytes) (line 360), which returns '0'.repeat(numBytes) — exactly numBytes ASCII bytes. So the bytes= value provably matches the upload body size, as the PR description claims. No behavioral risk for normal clients.
Style: Good. Dropping the && short-circuit idiom in favor of a plain assignment is cleaner now that the value is no longer conditional, and it remains consistent with the surrounding code.
Security: The change is the enabling half of a server-side byte ceiling. The cap itself is enforced server-side; this is just the client-supplied size signal. No new client-side concern. (Note: a custom/malicious client could still send bytes= that does not match the actual body — but enforcing that mismatch is necessarily a server responsibility, so nothing actionable here.)
Verification: pnpm build succeeds and all 93 unit tests pass on this branch.
LGTM — small, correct, and well-scoped. One optional note left inline.
|
Review posted on PR #122. Review summaryWhat it changes: A single-line change in Findings:
Comments posted to PR #122:
Overall: small, correct, and well-scoped — LGTM with only an optional suggestion. No commits pushed. |
Include the bytes= query parameter on upload (POST /__up) requests, not just downloads, matching the existing download behavior.
d3f7ff5 to
25ed00d
Compare
Send the
bytes=<size>query parameter on upload (POST /__up) requests, matching the existing behavior for download requests.No user-visible behavior change for normal clients:
bytes=matches the upload body size.