Skip to content

Commit e4b4b0f

Browse files
committed
optimize
1 parent 366dd56 commit e4b4b0f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

ctx.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,10 +1435,9 @@ type SendFile struct {
14351435
}
14361436

14371437
type sendFileStore struct {
1438-
filename string
14391438
handler fasthttp.RequestHandler
1440-
cacheControlValue string
14411439
config SendFile
1440+
cacheControlValue string
14421441
}
14431442

14441443
// compareConfig compares the current SendFile config with the new one
@@ -1490,7 +1489,7 @@ func (c *DefaultCtx) SendFile(file string, config ...SendFile) error {
14901489
var fsHandler fasthttp.RequestHandler
14911490
var cacheControlValue string
14921491
for _, sf := range c.app.sendfiles {
1493-
if sf.filename == filename && sf.compareConfig(cfg) {
1492+
if sf.compareConfig(cfg) {
14941493
fsHandler = sf.handler
14951494
cacheControlValue = sf.cacheControlValue
14961495
break
@@ -1519,9 +1518,8 @@ func (c *DefaultCtx) SendFile(file string, config ...SendFile) error {
15191518
}
15201519

15211520
sf := &sendFileStore{
1522-
filename: filename,
1523-
config: cfg,
1524-
handler: fasthttpFS.NewRequestHandler(),
1521+
config: cfg,
1522+
handler: fasthttpFS.NewRequestHandler(),
15251523
}
15261524

15271525
maxAge := cfg.MaxAge

ctx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,7 @@ func Test_Ctx_SendFile_Multiple(t *testing.T) {
31973197
require.NoError(t, err)
31983198
require.Contains(t, string(body), "type DefaultCtx struct")
31993199

3200-
require.Len(t, app.sendfiles, 4)
3200+
require.Len(t, app.sendfiles, 3)
32013201
}
32023202

32033203
// go test -race -run Test_Ctx_SendFile_Immutable

0 commit comments

Comments
 (0)