Skip to content

fix(http): probe with a ranged GET when HEAD gets no reply - #626

Merged
linroid merged 2 commits into
mainfrom
fix/http-head-dropped
Oct 23, 2026
Merged

linroid merged 2 commits into
mainfrom
fix/http-head-dropped

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Found while measuring throughput against Hetzner's public speed-test files:

ketch https://fsn1-speed.hetzner.com/100MB.bin
Download failed: Network: Network error occurred <- FailedRequest: HEAD https://fsn1-speed.hetzner.com/100MB.bin
  <- IOException: unexpected end of stream on https://fsn1-speed.hetzner.com/... <- EOFException: \n not found: limit=0 …

From here, HEAD gets an empty reply (the connection closes without a response; curl -I says the same), while GET with a range gets 206 Partial Content. Some servers and middleboxes, such as WAFs, drop HEAD like this. RangeSupportDetector fell back to its ranged GET probe (HttpEngine.probe) only when HEAD returned an HTTP status (400/403/404/405/500/501), so a dropped HEAD failed every attempt even though the file is reachable.

What changes

RangeSupportDetector.detect also probes when HEAD fails with KetchError.Network. If the probe fails too, as in a real outage, its error goes to the usual retries, at the cost of one extra quick request per attempt. Engines without a probe still rethrow the HEAD error. In tests, FakeHttpEngine gets failOnProbe, which defaults to failOnHead, so tests simulating an outage still see one.

Verification

  • ketch from this branch on https://fsn1-speed.hetzner.com/100MB.bin resolves through the probe and downloads, 43 MB in the first 60 s, about twice curl's single-connection speed on this route. Before: the error above after three retries.
  • New RangeSupportDetectorTest.detect_headDroppedOnTheNetwork_probesWithGet; detect_propagatesNetworkError now also checks the probe was tried.
  • ./gradlew :library:core:jvmTest passes.

https://fsn1-speed.hetzner.com/100MB.bin failed after three retries:
Hetzner's servers (and middleboxes that do the same) close the connection
on HEAD without a reply, while a GET gets the file. RangeSupportDetector
fell back to its ranged GET probe only for HEAD statuses; it now does for
network failures too. When the GET fails as well, as in an outage, its
error goes on to the usual retries.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T16:29:00.268787Z 518946c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@linroid
linroid force-pushed the fix/http-head-dropped branch from 9a146ba to 2addcf4 Compare October 23, 2026 16:27
@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 199 files  ±0   2 227 suites  ±0   55m 51s ⏱️ - 1m 0s
15 323 tests +4  15 055 ✅ +4  268 💤 ±0  0 ❌ ±0 
18 680 runs  +4  18 412 ✅ +4  268 💤 ±0  0 ❌ ±0 

Results for commit 2addcf4. ± Comparison against base commit c7c6457.

@linroid
linroid merged commit 8aa7a91 into main Oct 23, 2026
14 checks passed
@linroid
linroid deleted the fix/http-head-dropped branch October 23, 2026 17:15
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.

1 participant