Skip to content

Commit

Permalink
fix: improper use strings.TrimLeft
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma committed Aug 7, 2023
1 parent 8f6f20b commit 3e5d4c4
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/daemon/objectstorage/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (o *objectStorage) getObject(ctx *gin.Context) {
rg = &rangeValue

// Range header in dragonfly is without "bytes=".
urlMeta.Range = strings.TrimLeft(rangeHeader, "bytes=")
urlMeta.Range = strings.TrimPrefix(rangeHeader, "bytes=")

// When the request has a range header,
// there is no need to calculate md5, set this value to empty.
Expand Down
2 changes: 1 addition & 1 deletion client/daemon/peer/peertask_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func TestPeerTaskManager_TaskSuite(t *testing.T) {
}

if tc.httpRange != nil {
urlMeta.Range = strings.TrimLeft(tc.httpRange.String(), "bytes=")
urlMeta.Range = strings.TrimPrefix(tc.httpRange.String(), "bytes=")
}

if tc.urlGenerator != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/daemon/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (rt *transport) download(ctx context.Context, req *http.Request) (*http.Res
}
rg = &rgs[0]
// range in dragonfly is without "bytes="
meta.Range = strings.TrimLeft(rangeHeader, "bytes=")
meta.Range = strings.TrimPrefix(rangeHeader, "bytes=")
}

// Pick header's parameters
Expand Down
2 changes: 1 addition & 1 deletion client/dfget/dfget.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func parseHeader(s []string) map[string]string {
func newDownRequest(cfg *config.DfgetConfig, hdr map[string]string) *dfdaemonv1.DownRequest {
var rg string
if r, ok := hdr[headers.Range]; ok {
rg = strings.TrimLeft(r, "bytes=")
rg = strings.TrimPrefix(r, "bytes=")
} else {
rg = cfg.Range
}
Expand Down
2 changes: 1 addition & 1 deletion scheduler/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (j *job) preheat(ctx context.Context, req string) error {
if preheat.Headers != nil {
if r, ok := preheat.Headers[headers.Range]; ok {
// Range in dragonfly is without "bytes=".
urlMeta.Range = strings.TrimLeft(r, http.RangePrefix)
urlMeta.Range = strings.TrimPrefix(r, http.RangePrefix)
}
}

Expand Down

0 comments on commit 3e5d4c4

Please sign in to comment.