Skip to content

Commit d932f91

Browse files
committed
bugfix: return error if context is canceled.
1 parent 4618cbe commit d932f91

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kadai3/imura81gt/rget/rget.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ func (o *Option) downloadWithContext(
140140
}
141141

142142
// add range header
143-
fmt.Printf(fmt.Sprintf("bytes=%d-%d\n", o.Units[i].RangeStart, o.Units[i].RangeEnd))
144-
req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", o.Units[i].RangeStart, o.Units[i].RangeEnd))
143+
byteRange := fmt.Sprintf("bytes=%d-%d", o.Units[i].RangeStart, o.Units[i].RangeEnd)
144+
fmt.Println(byteRange)
145+
req.Header.Set("Range", byteRange)
145146

146147
client := http.DefaultClient
147148
resp, err := client.Do(req)
@@ -154,7 +155,7 @@ func (o *Option) downloadWithContext(
154155
select {
155156
case <-ctx.Done():
156157
fmt.Printf("Done: %v %+v\n", i, o.Units[i])
157-
return nil
158+
return fmt.Errorf("Error: %v", err)
158159
default:
159160
fmt.Println("default:", i, o.Units[i])
160161
}

0 commit comments

Comments
 (0)