diff --git a/go.mod b/go.mod index 50bbc8103250d8a2db2046647813493b4cb4f177..599170a97888c39f18de14c24d2e681b323dd5af 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/google/subcommands v1.2.0 github.com/jmcvetta/randutil v0.0.0-20150817122601-2bb1b664bcff github.com/kevinpollet/nego v0.0.0-20201213172553-d6ce2e30cfd6 // indirect - github.com/lpar/gzipped/v2 v2.0.2 + github.com/lpar/gzipped/v2 v2.1.0 github.com/miekg/dns v1.1.45 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/common v0.32.1 diff --git a/go.sum b/go.sum index 6afbb04dabaf8f8cce1100d40d99cda6cbb94acb..d45802df445e04f6ab0f896cb0e2617bf61d0e3b 100644 --- a/go.sum +++ b/go.sum @@ -350,6 +350,8 @@ github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-b github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lpar/gzipped/v2 v2.0.2 h1:y7FjyTH07f8dX0YQ5o0sg2DTbRnmS3oT1pUvxViQ//o= github.com/lpar/gzipped/v2 v2.0.2/go.mod h1:qb7pLOGFgqz5w9xGGiiRFPxuGZ7GqWEuXUKXSbgonkQ= +github.com/lpar/gzipped/v2 v2.1.0 h1:87/ug239roEqXLVOnXZg6NjDfFvMwmkGTKnFWJPUA9U= +github.com/lpar/gzipped/v2 v2.1.0/go.mod h1:G3UlFoFYzjCx6NV4zDmD1BIWMNBaJuKoUvxrEWJuZ3Y= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= diff --git a/vendor/github.com/lpar/gzipped/v2/.gitattributes b/vendor/github.com/lpar/gzipped/v2/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..fa1385d99a319b43c06f5309d1aae9fdd3adea46 --- /dev/null +++ b/vendor/github.com/lpar/gzipped/v2/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/vendor/github.com/lpar/gzipped/v2/.travis.yml b/vendor/github.com/lpar/gzipped/v2/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..f7a8f5c09cbd16723d407d4f41861dbda550e4dc --- /dev/null +++ b/vendor/github.com/lpar/gzipped/v2/.travis.yml @@ -0,0 +1,13 @@ +language: go + +go: + - 1.x + +before_install: + - go get -t -v ./... + +script: + - go test -race -coverprofile=coverage.txt -covermode=atomic + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/lpar/gzipped/v2/README.md b/vendor/github.com/lpar/gzipped/v2/README.md index 6c55f14f45f6bc547ac343bb0bb721426918c4fd..b1cebd089efae070c179d2577d76126ebec3873b 100644 --- a/vendor/github.com/lpar/gzipped/v2/README.md +++ b/vendor/github.com/lpar/gzipped/v2/README.md @@ -1,4 +1,6 @@ [](https://godoc.org/github.com/lpar/gzipped) +[](https://travis-ci.org/lpar/gzipped) +[](https://codecov.io/gh/lpar/gzipped) # gzipped.FileServer @@ -65,21 +67,21 @@ Accept-Encoding headers properly, and has unit tests. ## Caveats All requests are passed to Go's standard `http.ServeContent` method for -fulfilment. MIME type sniffing, accept ranges, content negotiation and other -tricky details are handled by that method. +fulfilment. MIME type mapping, accept ranges, content negotiation and other +tricky details are handled by that method. If the extension of a file doesn't have a defined MIME type, `ServeContent`'s sniffing may result in it assigning a MIME type such as `application/x-gzip` rather than what you might hope. See issue #18 for more information. It is up to you to ensure that your compressed and uncompressed resources are kept in sync. Directory browsing isn't supported. That includes remapping URLs ending in `/` to `index.html`, -`index.htm`, `Welcome.html` or whatever -- if you want URLs remapped that way, +`index.htm`, `Welcome.html` or whatever — if you want URLs remapped that way, I suggest having your router do it, or using middleware, so that you have control over the behavior. For example, to add support for `index.html` files in directories: ```go func withIndexHTML(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if strings.HasSuffix(r.URL.Path, "/") { + if strings.HasSuffix(r.URL.Path, "/") || len(r.URL.Path) == 0 { newpath := path.Join(r.URL.Path, "index.html") r.URL.Path = newpath } diff --git a/vendor/github.com/lpar/gzipped/v2/filesystem.go b/vendor/github.com/lpar/gzipped/v2/filesystem.go index 2faa408e710a00adffd6cf04d052ed8fa5ec16cc..4f268e26a1d940eba91434317179b27332ee0a66 100644 --- a/vendor/github.com/lpar/gzipped/v2/filesystem.go +++ b/vendor/github.com/lpar/gzipped/v2/filesystem.go @@ -1,6 +1,7 @@ package gzipped import ( + fs2 "io/fs" "net/http" "os" "path" @@ -29,13 +30,32 @@ func (d Dir) Exists(name string) bool { } fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name))) _, err := os.Stat(fullName) - if err != nil { - return false - } - return true + return err == nil } // Open defers to http.Dir's Open so that gzipped.Dir implements http.FileSystem. func (d Dir) Open(name string) (http.File, error) { return http.Dir(d).Open(name) } + +func FS(f fs2.FS) FileSystem { + return fs{fs: f} +} + +type fs struct { + fs fs2.FS +} + +// Exists tests whether a file with the specified name exists, resolved relative to the file system. +func (f fs) Exists(name string) bool { + if filepath.Separator != '/' && strings.ContainsRune(name, filepath.Separator) { + return false + } + _, err := fs2.Stat(f.fs, strings.TrimPrefix(filepath.FromSlash(path.Clean(name)), "/")) + return err == nil +} + +// Open defers to http.FS's Open so that gzipped.fs implements http.FileSystem. +func (f fs) Open(name string) (http.File, error) { + return http.FS(f.fs).Open(strings.TrimPrefix(name, "/")) +} diff --git a/vendor/github.com/lpar/gzipped/v2/go.mod b/vendor/github.com/lpar/gzipped/v2/go.mod index 2723db0284743b408a0643d47eb121b65cc25f92..0a424450aeedb805e2a63d82930bb0e36f34ce8d 100644 --- a/vendor/github.com/lpar/gzipped/v2/go.mod +++ b/vendor/github.com/lpar/gzipped/v2/go.mod @@ -1,7 +1,5 @@ module github.com/lpar/gzipped/v2 -require ( - github.com/kevinpollet/nego v0.0.0-20200324111829-b3061ca9dd9d -) +require github.com/kevinpollet/nego v0.0.0-20200324111829-b3061ca9dd9d -go 1.13 +go 1.18 diff --git a/vendor/github.com/lpar/gzipped/v2/go.sum b/vendor/github.com/lpar/gzipped/v2/go.sum index bf153be61f065c2e5ee6710e11333b166057f4ac..28393a64fd6321016581507b9a38afa630cc6571 100644 --- a/vendor/github.com/lpar/gzipped/v2/go.sum +++ b/vendor/github.com/lpar/gzipped/v2/go.sum @@ -2,14 +2,11 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/kevinpollet/nego v0.0.0-20200324111829-b3061ca9dd9d h1:BaIpmhcqpBnz4+NZjUjVGxKNA+/E7ovKsjmwqjXcGYc= github.com/kevinpollet/nego v0.0.0-20200324111829-b3061ca9dd9d/go.mod h1:3FSWkzk9h42opyV0o357Fq6gsLF/A6MI/qOca9kKobY= -github.com/lpar/accept v0.1.0 h1:q4+k1TJuCfoe8cIBRLTfiMMoiaHKpn1rlD1yYE/wj7o= -github.com/lpar/accept v0.1.0/go.mod h1:/ZcJqAhzugu4J4EZ7hwixKslL0y07dMxQzIZZLpbZbk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/lpar/gzipped/v2/testdata/file.txt b/vendor/github.com/lpar/gzipped/v2/testdata/file.txt new file mode 100644 index 0000000000000000000000000000000000000000..e1993644d07fc23b02cf1c6e59d16bc0cc1a2cec --- /dev/null +++ b/vendor/github.com/lpar/gzipped/v2/testdata/file.txt @@ -0,0 +1 @@ +zyxwvutsrqponmlkjihgfedcba diff --git a/vendor/github.com/lpar/gzipped/v2/testdata/file.txt.gz b/vendor/github.com/lpar/gzipped/v2/testdata/file.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..c3cc069a60a682045d28f9ae3ea4221ffb4bb872 Binary files /dev/null and b/vendor/github.com/lpar/gzipped/v2/testdata/file.txt.gz differ diff --git a/vendor/github.com/lpar/gzipped/v2/testdata/file2.txt b/vendor/github.com/lpar/gzipped/v2/testdata/file2.txt new file mode 100644 index 0000000000000000000000000000000000000000..db38b549b14b6b50324e70223d57ac2c2414d162 --- /dev/null +++ b/vendor/github.com/lpar/gzipped/v2/testdata/file2.txt @@ -0,0 +1 @@ +1234567890987654321 diff --git a/vendor/modules.txt b/vendor/modules.txt index 9a1dc6d92e902b964b588421936bd96476a27c80..a0e46a32ea13d7ae8f414e1d5f0cacaf57602e90 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -58,7 +58,7 @@ github.com/json-iterator/go # github.com/kevinpollet/nego v0.0.0-20201213172553-d6ce2e30cfd6 ## explicit github.com/kevinpollet/nego -# github.com/lpar/gzipped/v2 v2.0.2 +# github.com/lpar/gzipped/v2 v2.1.0 ## explicit github.com/lpar/gzipped/v2 # github.com/matttproud/golang_protobuf_extensions v1.0.1