Fix tests: use StartTestCustomServer (no Content-Length) to match real bug scenario

Remove StartTestNoRangeServer and its tests since the real bug is about
servers that don't return Content-Length at all (like GitHub's zip downloads),
not servers with Content-Length but no Range support.

The chunked tests (TestFetcher_DownloadChunkedContinue and
TestFetcher_DownloadChunkedNotExceedSize) correctly simulate the real-world
bug using StartTestCustomServer which serves files without Content-Length.

Co-authored-by: monkeyWie <[email protected]>
This commit is contained in:
copilot-swe-agent[bot]andmonkeyWie committed 2026-03-11 10:53:52 +00:00
1 parent b8e517b35b
commit 8b02844ec3
2 files changed
+4 -74

No files matched your search

-19
View File
@@ -636,25 +636,6 @@ func StartTestRangeBugServer() net.Listener {
})
}
// StartTestNoRangeServer starts a server that returns Content-Length but does NOT support Range requests.
// This simulates servers where file size is known but range downloads are not supported.
func StartTestNoRangeServer() net.Listener {
return startTestServer(func(sl *shutdownListener) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/"+BuildName, func(writer http.ResponseWriter, request *http.Request) {
file, err := os.Open(BuildFile)
if err != nil {
panic(err)
}
defer file.Close()
writer.Header().Set("Content-Length", fmt.Sprintf("%d", BuildSize))
writer.WriteHeader(200)
io.Copy(writer, file)
})
return mux
})
}
func rangeFileHandle(writer http.ResponseWriter, request *http.Request, modifyEnd func(end int64) int64, iocpN func(file *os.File, n int64)) {
r := request.Header.Get("Range")