XTLS/Xray-core · error · errors.Error
empty response body
Error message
empty response body
What it means
Returned by downloadOne when the HTTP response was successful (2xx) but io.Copy transferred 0 bytes from the body to the staged temp file. An empty geodata file cannot be a valid protobuf/-dat payload, so it is rejected rather than written to disk.
Source
Thrown at app/geodata/download.go:221
client = d.httpClient
}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
io.Copy(io.Discard, resp.Body)
return errors.New("unexpected status code: ", resp.StatusCode)
}
n, err := io.Copy(writer, resp.Body)
if err != nil {
return err
}
if n == 0 {
return errors.New("empty response body")
}
return nil
}
func clean(assets []stage) {
for _, asset := range assets {
if asset.temp != "" {
os.Remove(asset.temp)
}
}
}
type tx struct {
swaps []swap
}
type swap struct {
target stringView on GitHub (pinned to 7d214f8b09)
Solutions
- curl the asset URL and check the downloaded size matches a real geosite/geoip file (MBs, not 0)
- Switch to the official mirror
- Retry — empty responses from CDN edges are often transient
Defensive patterns
Strategy: validation
Validate before calling
// After download (if you wrap it), sanity-check the file size:
fi, err := os.Stat(stagedFile)
if err == nil && fi.Size() == 0 {
return errors.New("mirror returned empty geodata file; discarding")
} Prevention
- Prefer reputable mirrors that serve full-size files
- Keep known-good geodata files on disk so empty downloads never take effect
- The downloader already stages to temp files — never bypass that staging
When it happens
Trigger: A mirror returning 200 with an empty body (or a body that closes immediately) for a geodata asset; Content-Length: 0 responses from a broken CDN edge.
Common situations: Corrupt/misconfigured mirror; truncated uploads by the file host; anti-bot endpoints returning 200 with empty content.
Related errors
- connection idle timeout
- cannot understand address
- cannot dial remote address
- cannot finish connection
- redirected to non-https URL:
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/c8096801899392d9.
Report an issue: GitHub.