mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-04 15:58:13 +08:00
parent
426cb84255
commit
df22205385
@ -37,6 +37,15 @@ func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r
|
||||
return
|
||||
}
|
||||
|
||||
if size == 0 {
|
||||
// We override null files to 200 to avoid issues with fragment caching reverse proxies.
|
||||
// Also whatever you are asking for, it's cheaper to just give you the complete file (nothing).
|
||||
// TODO: remove this if clause once https://github.com/golang/go/issues/54794 is fixed in two latest releases of go
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
// Lazy seeker enables efficient range-requests and HTTP HEAD responses
|
||||
content := &lazySeeker{
|
||||
size: size,
|
||||
|
||||
@ -103,6 +103,14 @@ test_expect_success "GET IPFS inlined zero-length data object returns ok code (2
|
||||
test_should_contain "Content-Length: 0" empty_ok_response
|
||||
'
|
||||
|
||||
# https://github.com/ipfs/kubo/issues/9238
|
||||
test_expect_success "GET IPFS inlined zero-length data object with byte range returns ok code (200)" '
|
||||
curl -sD - "http://127.0.0.1:$port/ipfs/bafkqaaa" -H "Range: bytes=0-1048575" > empty_ok_response &&
|
||||
test_should_contain "HTTP/1.1 200 OK" empty_ok_response &&
|
||||
test_should_contain "Content-Length: 0" empty_ok_response &&
|
||||
test_should_contain "Content-Type: text/plain" empty_ok_response
|
||||
'
|
||||
|
||||
test_expect_success "GET /ipfs/ipfs/{cid} returns redirect to the valid path" '
|
||||
curl -sD - "http://127.0.0.1:$port/ipfs/ipfs/bafkqaaa?query=to-remember" > response_with_double_ipfs_ns &&
|
||||
test_should_contain "<meta http-equiv=\"refresh\" content=\"10;url=/ipfs/bafkqaaa?query=to-remember\" />" response_with_double_ipfs_ns &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user