Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improper use strings.TrimLeft #2603

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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