• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-pkgz / rest / 32197883937
97%

Build:
DEFAULT BRANCH: master
Ran 18 Aug 2026 11:37PM UTC
Jobs 1
Files 25
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

18 Aug 2026 11:36PM UTC coverage: 97.493% (+0.04%) from 97.451%
32197883937

push

github

web-flow
Negotiate gzip on the response content type (#51)

* fix: negotiate gzip on the response content type

Previously the middleware picked compression from the request Content-Type,
which a normal GET does not send, so it fell back to application/octet-stream
and skipped compression for exactly the JSON and HTML responses it exists to
compress. A request that did carry a matching type could equally get an
unrelated binary response compressed. The old tests set a request Content-Type,
which is why they passed.

The decision now waits until the response content type is known, taken from the
handler's header or sniffed from the first chunk when it set none. Along the
way: Accept-Encoding is parsed so gzip;q=0 is honoured, bodyless 204 and 304
responses are left alone, Content-Length is dropped only when the body is
actually compressed, and Flush, Hijack and Unwrap pass through so streaming and
protocol upgrades keep working.

* docs: describe gzip response-based negotiation

* fix: tighten when the gzip writer compresses and how it commits

Six defects in the new writer, each with a test that fails without the fix:

Flush before the first write committed the headers while the compression
decision was still open, so a later textual write went out gzipped under
identity headers. The decision is now settled before the headers leave.

A panicking handler was committed as 200 by the deferred close, which left an
outer Recoverer unable to replace it with a 500. An uncommitted response is now
left alone when the handler did not return normally.

A response the handler had already encoded was compressed again and relabelled
gzip, and a 206 was compressed although its Content-Range offsets describe the
uncompressed representation. Both are skipped now.

WriteHeader let a second call replace the status when the first could not commit
for want of a content type, where net/http keeps the first. Interim 1xx
responses pass straight through, so Early Hints no longer becom... (continued)

135 of 137 new or added lines in 1 file covered. (98.54%)

1633 of 1675 relevant lines covered (97.49%)

47.63 hits per line

Uncovered Changes

Lines Coverage ∆ File
2
98.7
-1.3% gzip.go
Jobs
ID Job ID Ran Files Coverage
1 32197883937.1 18 Aug 2026 11:37PM UTC 25
97.49
GitHub Action Run
Source Files on build 32197883937
  • Tree
  • List 25
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 7e0b6652 on github
  • Prev Build on master (#32197356726)
  • Next Build on master (#32198203704)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc