Import upstream version 0.0~git20200329.0.98214d7
Debian Janitor
3 years ago
0 | name: Go | |
1 | on: | |
2 | push: | |
3 | branches: [master] | |
4 | pull_request: | |
5 | env: | |
6 | GOPROXY: "https://proxy.golang.org" | |
7 | ||
8 | jobs: | |
9 | lint: | |
10 | name: Lint | |
11 | runs-on: ubuntu-latest | |
12 | steps: | |
13 | - uses: actions/checkout@v2 | |
14 | - name: Run golangci-lint | |
15 | uses: actions-contrib/golangci-lint@v1 | |
16 | ||
17 | test: | |
18 | name: Test | |
19 | strategy: | |
20 | matrix: | |
21 | go-version: [1.13.x, 1.14.x] | |
22 | platform: [ubuntu-latest, macos-latest, windows-latest] | |
23 | runs-on: ${{ matrix.platform }} | |
24 | steps: | |
25 | - name: Install Go | |
26 | uses: actions/setup-go@v1 | |
27 | with: | |
28 | go-version: ${{ matrix.go-version }} | |
29 | - name: Checkout code | |
30 | uses: actions/checkout@v2 | |
31 | - name: Run unit tests | |
32 | run: go test -v -race -coverprofile=coverage -covermode=atomic ./... | |
33 | - name: Upload coverage report to Codecov | |
34 | uses: codecov/codecov-action@v1.0.6 | |
35 | with: | |
36 | file: ./coverage | |
37 | flags: unittests | |
38 | - name: Cache downloaded modules | |
39 | uses: actions/cache@v1 | |
40 | with: | |
41 | path: ~/go/pkg/mod | |
42 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
43 | restore-keys: | | |
44 | ${{ runner.os }}-go- |
0 | name: LSIF | |
1 | on: [push] | |
2 | jobs: | |
3 | build: | |
4 | runs-on: ubuntu-latest | |
5 | steps: | |
6 | - uses: actions/checkout@v1 | |
7 | - name: Generate LSIF data | |
8 | uses: sourcegraph/lsif-go-action@master | |
9 | with: | |
10 | verbose: 'true' | |
11 | - name: Upload LSIF data | |
12 | uses: sourcegraph/lsif-upload-action@master | |
13 | continue-on-error: true | |
14 | with: | |
15 | endpoint: https://sourcegraph.com | |
16 | github_token: ${{ secrets.GITHUB_TOKEN }} |
0 | sudo: false | |
1 | language: go | |
2 | ||
3 | go: | |
4 | - 1.3 | |
5 | - 1.4 | |
6 | - 1.5 | |
7 | - tip | |
8 | ||
9 | script: go test -v -cover -race | |
10 | ||
11 | notifications: | |
12 | email: | |
13 | - u@gogs.io |
0 | # gzip [![Build Status](https://travis-ci.org/go-macaron/gzip.svg?branch=master)](https://travis-ci.org/go-macaron/gzip) [![](http://gocover.io/_badge/github.com/go-macaron/gzip)](http://gocover.io/github.com/go-macaron/gzip) | |
0 | # gzip | |
1 | ||
2 | [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-macaron/gzip/Go?logo=github&style=for-the-badge)](https://github.com/go-macaron/gzip/actions?query=workflow%3AGo) | |
3 | [![codecov](https://img.shields.io/codecov/c/github/go-macaron/gzip/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-macaron/gzip) | |
4 | [![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/go-macaron/gzip?tab=doc) | |
5 | [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-macaron/gzip) | |
1 | 6 | |
2 | 7 | Middleware gzip provides compress to responses for [Macaron](https://github.com/go-macaron/macaron). |
3 | 8 | |
8 | 13 | ## Getting Help |
9 | 14 | |
10 | 15 | - [API Reference](https://gowalker.org/github.com/go-macaron/gzip) |
11 | - [Documentation](http://go-macaron.com/docs/middlewares/gzip) | |
16 | - [Documentation](https://go-macaron.com/middlewares/gzip) | |
12 | 17 | |
13 | 18 | ## Credits |
14 | 19 | |
16 | 21 | |
17 | 22 | ## License |
18 | 23 | |
19 | This project is under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for the full license text.⏎ | |
24 | This project is under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for the full license text. |
0 | coverage: | |
1 | range: "60...95" | |
2 | status: | |
3 | project: | |
4 | default: | |
5 | threshold: 1% | |
6 | ||
7 | comment: | |
8 | layout: 'diff, files' |
0 | module github.com/go-macaron/gzip | |
1 | ||
2 | go 1.13 | |
3 | ||
4 | require ( | |
5 | github.com/klauspost/compress v1.10.3 | |
6 | github.com/smartystreets/goconvey v1.6.4 | |
7 | gopkg.in/macaron.v1 v1.3.5 | |
8 | ) |
0 | github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 h1:NjHlg70DuOkcAMqgt0+XA+NHwtu66MkTVVgR4fFWbcI= | |
1 | github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw= | |
2 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | |
3 | github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | |
4 | github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | |
5 | github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= | |
6 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= | |
7 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= | |
8 | github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8= | |
9 | github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= | |
10 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | |
11 | github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | |
12 | github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= | |
13 | github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= | |
14 | github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= | |
15 | github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= | |
16 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= | |
17 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= | |
18 | github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM= | |
19 | github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= | |
20 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | |
21 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= | |
22 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | |
23 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | |
24 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | |
25 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |
26 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |
27 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |
28 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | |
29 | gopkg.in/ini.v1 v1.46.0 h1:VeDZbLYGaupuvIrsYCEOe/L/2Pcs5n7hdO1ZTjporag= | |
30 | gopkg.in/ini.v1 v1.46.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= | |
31 | gopkg.in/macaron.v1 v1.3.5 h1:FUA16VFBojxzfU75KqWrV/6BPv9O2R1GnybSGRie9QQ= | |
32 | gopkg.in/macaron.v1 v1.3.5/go.mod h1:uMZCFccv9yr5TipIalVOyAyZQuOH3OkmXvgcWwhJuP4= |
28 | 28 | const ( |
29 | 29 | _HEADER_ACCEPT_ENCODING = "Accept-Encoding" |
30 | 30 | _HEADER_CONTENT_ENCODING = "Content-Encoding" |
31 | _HEADER_CONTENT_LENGTH = "Content-Length" | |
32 | 31 | _HEADER_CONTENT_TYPE = "Content-Type" |
33 | 32 | _HEADER_VARY = "Vary" |
34 | 33 | ) |
85 | 84 | gzw := gzipResponseWriter{gz, ctx.Resp} |
86 | 85 | ctx.Resp = gzw |
87 | 86 | ctx.MapTo(gzw, (*http.ResponseWriter)(nil)) |
88 | if ctx.Render != nil { | |
87 | ||
88 | // Check if render middleware has been registered, | |
89 | // if yes, we need to modify ResponseWriter for it as well. | |
90 | if _, ok := ctx.Render.(*macaron.DummyRender); !ok { | |
89 | 91 | ctx.Render.SetResponseWriter(gzw) |
90 | 92 | } |
91 | 93 |
45 | 45 | So(err, ShouldBeNil) |
46 | 46 | m.ServeHTTP(resp, req) |
47 | 47 | |
48 | _, ok := resp.HeaderMap[_HEADER_CONTENT_ENCODING] | |
48 | _, ok := resp.Result().Header[_HEADER_CONTENT_ENCODING] | |
49 | 49 | So(ok, ShouldBeFalse) |
50 | 50 | |
51 | 51 | ce := resp.Header().Get(_HEADER_CONTENT_ENCODING) |
56 | 56 | req.Header.Set(_HEADER_ACCEPT_ENCODING, "gzip") |
57 | 57 | m.ServeHTTP(resp, req) |
58 | 58 | |
59 | _, ok = resp.HeaderMap[_HEADER_CONTENT_ENCODING] | |
59 | _, ok = resp.Result().Header[_HEADER_CONTENT_ENCODING] | |
60 | 60 | So(ok, ShouldBeTrue) |
61 | 61 | |
62 | 62 | ce = resp.Header().Get(_HEADER_CONTENT_ENCODING) |
94 | 94 | hj, ok := rw.(http.Hijacker) |
95 | 95 | So(ok, ShouldBeTrue) |
96 | 96 | |
97 | hj.Hijack() | |
97 | _, _, err := hj.Hijack() | |
98 | So(err, ShouldBeNil) | |
98 | 99 | }) |
99 | 100 | |
100 | 101 | r, err := http.NewRequest("GET", "/", nil) |