mirror of
https://github.com/axllent/mailpit.git
synced 2025-08-15 20:13:16 +02:00
Feature: Add configuration to explicitly disable HTTP compression in web UI/API (#448)
This commit is contained in:
@@ -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().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().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.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
|
// SMTP server
|
||||||
rootCmd.Flags().StringVarP(&config.SMTPListen, "smtp", "s", config.SMTPListen, "SMTP bind interface and port")
|
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") {
|
if getEnabledFromEnv("MP_ALLOW_UNTRUSTED_TLS") {
|
||||||
config.AllowUntrustedTLS = true
|
config.AllowUntrustedTLS = true
|
||||||
}
|
}
|
||||||
|
if getEnabledFromEnv("MP_DISABLE_HTTP_COMPRESSION") {
|
||||||
|
config.DisableHTTPCompression = true
|
||||||
|
}
|
||||||
|
|
||||||
// SMTP server
|
// SMTP server
|
||||||
if len(os.Getenv("MP_SMTP_BIND_ADDR")) > 0 {
|
if len(os.Getenv("MP_SMTP_BIND_ADDR")) > 0 {
|
||||||
|
@@ -65,6 +65,9 @@ var (
|
|||||||
// Webroot to define the base path for the UI and API
|
// Webroot to define the base path for the UI and API
|
||||||
Webroot = "/"
|
Webroot = "/"
|
||||||
|
|
||||||
|
// DisableHTTPCompression will explicitly disable HTTP compression in the web UI and API
|
||||||
|
DisableHTTPCompression bool
|
||||||
|
|
||||||
// SMTPTLSCert file
|
// SMTPTLSCert file
|
||||||
SMTPTLSCert string
|
SMTPTLSCert string
|
||||||
|
|
||||||
|
@@ -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)
|
fn(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user