1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-08-13 20:04:49 +02:00

Feature: Add configuration to explicitly disable HTTP compression in web UI/API (#448)

This commit is contained in:
Ralph Slooten
2025-03-01 14:43:38 +13:00
parent 6e9760d5d9
commit 876d0eb5da
3 changed files with 8 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ func init() {
rootCmd.Flags().BoolVar(&config.BlockRemoteCSSAndFonts, "block-remote-css-and-fonts", config.BlockRemoteCSSAndFonts, "Block access to remote CSS & fonts")
rootCmd.Flags().StringVar(&config.EnableSpamAssassin, "enable-spamassassin", config.EnableSpamAssassin, "Enable integration with SpamAssassin")
rootCmd.Flags().BoolVar(&config.AllowUntrustedTLS, "allow-untrusted-tls", config.AllowUntrustedTLS, "Do not verify HTTPS certificates (link checker & screenshots)")
rootCmd.Flags().BoolVar(&config.DisableHTTPCompression, "disable-http-compression", config.DisableHTTPCompression, "Disable HTTP compression support (web UI & API)")
// SMTP server
rootCmd.Flags().StringVarP(&config.SMTPListen, "smtp", "s", config.SMTPListen, "SMTP bind interface and port")
@@ -237,6 +238,9 @@ func initConfigFromEnv() {
if getEnabledFromEnv("MP_ALLOW_UNTRUSTED_TLS") {
config.AllowUntrustedTLS = true
}
if getEnabledFromEnv("MP_DISABLE_HTTP_COMPRESSION") {
config.DisableHTTPCompression = true
}
// SMTP server
if len(os.Getenv("MP_SMTP_BIND_ADDR")) > 0 {

View File

@@ -65,6 +65,9 @@ var (
// Webroot to define the base path for the UI and API
Webroot = "/"
// DisableHTTPCompression will explicitly disable HTTP compression in the web UI and API
DisableHTTPCompression bool
// SMTPTLSCert file
SMTPTLSCert string

View File

@@ -253,7 +253,7 @@ func middleWareFunc(fn http.HandlerFunc) http.HandlerFunc {
}
}
if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
if config.DisableHTTPCompression || !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
fn(w, r)
return
}