<commit_before>package gzip

import (
	"net/http"

	"github.com/NYTimes/gziphandler"
)

var Default = func(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
	handle := gziphandler.GzipHandler(next)
	handle.ServeHTTP(rw, req)
}

func New(lvl int) func(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
	handler := gziphandler.MustNewGzipLevelHandler(lvl)

	return func(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
		handle := handler(next)
		handle.ServeHTTP(rw, req)
	}
}<commit_msg>server: Tweak gzip middleware to only work on paths with extensions.<commit_after>package gzip

import (
	"compress/gzip"
	"net/http"
	"path"

	"github.com/NYTimes/gziphandler"
)

var Default = New(gzip.DefaultCompression)

func New(lvl int) func(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
	handler := gziphandler.MustNewGzipLevelHandler(lvl)

	return func(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
		// todo: whitelist gzippable data
		if path.Ext(req.URL.Path) == "" {
			next(rw, req)
			return
		}
		handle := handler(next)
		handle.ServeHTTP(rw, req)
	}
}
{'fraction_non_alphanumeric': 0.12489158716392021, 'fraction_numerical': 0.0, 'mean_word_length': 4.887755102040816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208322', 'n_tokens_mistral': 424, 'n_tokens_neox': 406, 'n_words': 90}