1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 05:12:49 +00:00

use getString in Range(#312)

* Transform string in Range without allocation
This commit is contained in:
bestgopher 2020-04-27 12:28:53 +08:00 committed by GitHub
parent 101e1cce98
commit 260f3b3410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
ctx.go
View File

@ -603,7 +603,7 @@ func (ctx *Ctx) Query(key string) (value string) {
// Range returns a struct containing the type and a slice of ranges.
func (ctx *Ctx) Range(size int) (rangeData Range, err error) {
rangeStr := string(ctx.Fasthttp.Request.Header.Peek(HeaderRange))
rangeStr := getString(ctx.Fasthttp.Request.Header.Peek(HeaderRange))
if rangeStr == "" || !strings.Contains(rangeStr, "=") {
return rangeData, fmt.Errorf("malformed range header string")
}