pkg/ranger: fix linting errors
This commit is contained in:
parent
bc1d0deb11
commit
d84757d49a
@ -7,4 +7,5 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
)
|
||||
|
||||
// Error is the errs class of standard Ranger errors
|
||||
var Error = errs.Class("ranger error")
|
||||
|
@ -175,10 +175,9 @@ func checkPreconditions(w http.ResponseWriter, r *http.Request,
|
||||
if r.Method == "GET" || r.Method == "HEAD" {
|
||||
writeNotModified(w)
|
||||
return true, ""
|
||||
} else {
|
||||
w.WriteHeader(http.StatusPreconditionFailed)
|
||||
return true, ""
|
||||
}
|
||||
w.WriteHeader(http.StatusPreconditionFailed)
|
||||
return true, ""
|
||||
case condNone:
|
||||
if checkIfModifiedSince(r, modtime) == condFalse {
|
||||
writeNotModified(w)
|
||||
@ -311,9 +310,8 @@ func checkIfRange(w http.ResponseWriter, r *http.Request, modtime time.Time) (
|
||||
if etag != "" {
|
||||
if etagStrongMatch(etag, w.Header().Get("Etag")) {
|
||||
return condTrue
|
||||
} else {
|
||||
return condFalse
|
||||
}
|
||||
return condFalse
|
||||
}
|
||||
// The If-Range value is typically the ETag value, but it may also be
|
||||
// the modtime date. See golang.org/issue/8367.
|
||||
|
@ -32,8 +32,10 @@ func (f *fatalReader) Read(p []byte) (n int, err error) {
|
||||
// ByteRanger turns a byte slice into a Ranger
|
||||
type ByteRanger []byte
|
||||
|
||||
// Size implements Ranger.Size
|
||||
func (b ByteRanger) Size() int64 { return int64(len(b)) }
|
||||
|
||||
// Range implements Ranger.Range
|
||||
func (b ByteRanger) Range(offset, length int64) io.Reader {
|
||||
if offset < 0 {
|
||||
return FatalReader(Error.New("negative offset"))
|
||||
|
Loading…
Reference in New Issue
Block a user