Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
refactor: use bytes instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Feb 1, 2018
1 parent 1a315cf commit 1eb0ff1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fresh.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fresh

import (
"bytes"
"regexp"
"time"
)
Expand Down Expand Up @@ -67,15 +68,16 @@ func Fresh(reqHeader *RequestHeader, resHeader *ResponseHeader) bool {
}
// if none match
if len(noneMatch) != 0 && (len(noneMatch) != 1 || noneMatch[0] != byte('*')) {
etag := string(resHeader.ETag)
etag := resHeader.ETag
if len(etag) == 0 {
return false
}
matches := parseTokenList(noneMatch)
etagStale := true
for _, match := range matches {
str := string(match)
if str == etag || str == "W/"+etag || "W/"+str == etag {
if bytes.Equal(match, etag) ||
bytes.Equal(match, append([]byte("W/"), etag...)) ||
bytes.Equal(append([]byte("W/"), match...), etag) {
etagStale = false
break
}
Expand Down

0 comments on commit 1eb0ff1

Please sign in to comment.