mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-19 17:56:32 +03:00
lib/netutil: move IsTrivialNetworkError() function there, since it is used in multiple places across the code
This commit is contained in:
@@ -199,7 +199,7 @@ func gzipHandler(s *server, rh RequestHandler) http.HandlerFunc {
|
||||
w = maybeGzipResponseWriter(w, r)
|
||||
handlerWrapper(s, w, r, rh)
|
||||
if zrw, ok := w.(*gzipResponseWriter); ok {
|
||||
if err := zrw.Close(); err != nil && !isTrivialNetworkError(err) {
|
||||
if err := zrw.Close(); err != nil && !netutil.IsTrivialNetworkError(err) {
|
||||
logger.Warnf("gzipResponseWriter.Close: %s", err)
|
||||
}
|
||||
}
|
||||
@@ -503,10 +503,10 @@ func (zrw *gzipResponseWriter) Flush() {
|
||||
_, _ = zrw.Write(nil)
|
||||
}
|
||||
if !zrw.disableCompression {
|
||||
if err := zrw.bw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||
if err := zrw.bw.Flush(); err != nil && !netutil.IsTrivialNetworkError(err) {
|
||||
logger.Warnf("gzipResponseWriter.Flush (buffer): %s", err)
|
||||
}
|
||||
if err := zrw.zw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||
if err := zrw.zw.Flush(); err != nil && !netutil.IsTrivialNetworkError(err) {
|
||||
logger.Warnf("gzipResponseWriter.Flush (gzip): %s", err)
|
||||
}
|
||||
}
|
||||
@@ -643,14 +643,6 @@ func (e *ErrorWithStatusCode) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
func isTrivialNetworkError(err error) bool {
|
||||
s := err.Error()
|
||||
if strings.Contains(s, "broken pipe") || strings.Contains(s, "reset by peer") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsTLS indicates is tls enabled or not
|
||||
func IsTLS() bool {
|
||||
return *tlsEnable
|
||||
|
||||
Reference in New Issue
Block a user