GoogleChromeLabs / simplehttp2server

A simple HTTP/2 server for development
Other
1.74k stars 98 forks source link

call gzip for all text-based formats #39

Closed crossi36 closed 5 years ago

crossi36 commented 5 years ago

This fixes a subtle bug that prevented some text-based formats from being gzipped.

Contrary to other languages (where the fall through is implicit and you need to call break explicitly) in Go the break is implicit and you need to explicitly fall through to other cases in a switch.

From the Go tour:

Go's switch is like the one in C, C++, Java, JavaScript, and PHP, except that Go only runs the selected case, not all the cases that follow. In effect, the break statement that is needed at the end of each case in those languages is provided automatically in Go.

Demonstration on the Go playground: https://play.golang.org/p/7g39bJz_4CH

surma commented 5 years ago

I always thought the multi-case block was special-cased. Dayum. Thanks for the fix.