Skip to content

fix(server): keep HEAD requests out of download sessions - #399

Merged
claudiodangelis merged 2 commits into
claudiodangelis:mainfrom
anishpentyala:fix-head-download-session
Nov 22, 2026
Merged

claudiodangelis merged 2 commits into
claudiodangelis:mainfrom
anishpentyala:fix-head-download-session

Conversation

@anishpentyala

Copy link
Copy Markdown
Contributor

Related to #384.

A browser-like HEAD request currently claims a download session and ends it when metadata serving returns. With keep-alive disabled, the server can stop before a following GET downloads the file. The narrower reproduction was announced in #384 (comment) before this patch.

Keep HEAD requests outside download-session counting and completion, while preserving the existing session-cookie check under the mutex. HEAD still uses the existing headers and standard-library file-serving path. Normal browser GET, overlapping range downloads, keep-alive, and non-Mozilla handling keep their existing behavior. This is not a new authentication boundary.

The four new test groups cover metadata before a session, cookie checks during a session, a held HEAD during real download completion, and overlapping full/range HTTP transfers. They check that HEAD does not claim a cookie, stop the server, delete the temporary body, or change the download count, and that real GETs still finish and shut down normally. The held-HEAD case tests bookkeeping, not a promise that graceful HTTP shutdown never waits for an in-flight handler.

Validation on Linux with actual Go 1.21.13, 1.24.1, and 1.26.6:

  • go test ./server, go test -race ./server, go build ./..., and go vet ./... pass on each version.
  • Full go test ./... is not green here: only config.TestNew fails because this environment has no eligible network interface. The same failure occurs on untouched base 193a4e01 on all three versions. Other packages pass or have no tests.
  • Windows/amd64 and Darwin/amd64 server test binaries cross-compile with Go 1.26.6. They were not executed on those systems.

This addresses one measured HEAD-triggered early-shutdown path. No real phone or scanner reproduction is claimed, and this does not establish that every scanner-preview case in #384 is fixed.

@claudiodangelis
claudiodangelis merged commit a8ce97a into claudiodangelis:main Nov 22, 2026
claudiodangelis added a commit that referenced this pull request Nov 22, 2026
…#400)

Fixes the staticcheck QF1003 lint failure on main introduced by #399.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants