Skip to content

Commit 51943e8

Browse files
bajtosCopilot
andauthored
example_range_test: support empty range
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f609a6d commit 51943e8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

example_range_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ func ExampleDecryptRange() {
4848
// Both are known up front, so a handler can write its headers before
4949
// decrypting a single chunk.
5050
fmt.Printf("Content-Length: %d\n", r.Len())
51+
if r.Len() == 0 {
52+
fmt.Printf("Content-Range: bytes */%d\n", r.Size())
53+
return
54+
}
5155
fmt.Printf("Content-Range: bytes %d-%d/%d\n", off, off+r.Len()-1, r.Size())
52-
5356
got, err := io.ReadAll(r)
5457
if err != nil {
5558
log.Fatal(err)

0 commit comments

Comments
 (0)