Repository navigation
fix(server): keep HEAD requests out of download sessions - #399
Merged
claudiodangelis merged 2 commits intoNov 22, 2026
Merged
claudiodangelis merged 2 commits into
claudiodangelis merged 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ./..., andgo vet ./...pass on each version.go test ./...is not green here: onlyconfig.TestNewfails because this environment has no eligible network interface. The same failure occurs on untouched base193a4e01on all three versions. Other packages pass or have no tests.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.