MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / compressWrite

Method compressWrite

internal/waf/captcha_validator.go:922–933  ·  view source on GitHub ↗
(req *http.Request, writer http.ResponseWriter, htmlContent []byte)

Source from the content-addressed store, hash-verified

920}
921
922func (this *CaptchaValidator) compressWrite(req *http.Request, writer http.ResponseWriter, htmlContent []byte) {
923 var acceptEncoding = req.Header.Get("Accept-Encoding")
924 if strings.Contains(acceptEncoding, "gzip") {
925 this.compressGzip(writer, htmlContent)
926 } else if strings.Contains(acceptEncoding, "br") {
927 this.compressBR(writer, htmlContent)
928 } else {
929 writer.Header().Set("Content-Length", types.String(len(htmlContent)))
930 writer.WriteHeader(http.StatusOK)
931 _, _ = writer.Write(htmlContent)
932 }
933}
934
935func (this *CaptchaValidator) compressBR(writer http.ResponseWriter, htmlContent []byte) {
936 compressWriter, err := compressions.NewBrotliWriter(writer, 0)

Callers 1

showGeeTestFormMethod · 0.95

Calls 9

compressGzipMethod · 0.95
compressBRMethod · 0.95
WriteHeaderMethod · 0.65
WriteMethod · 0.65
GetMethod · 0.45
ContainsMethod · 0.45
SetMethod · 0.45
HeaderMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected