Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Handle informational and bodyless gzip responses
rcourtman90081dacb424
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 1d0843c7a9..7d5500c840 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -202,9 +202,11 @@ change may globally weaken the Task 03 lifecycle-state idempotency invariant.`pkg/server/gzip_middleware.go`. Negotiation must combine every`Accept-Encoding` field line, honor strict RFC qvalues and explicit gzipexclusions, and bypass token-valid WebSocket upgrades before wrapping the- response writer. Once a successful response advertises gzip, explicit- empty bodies must still emit a valid empty gzip member. Regression proof- lives in `pkg/server/gzip_middleware_test.go`.+ response writer. Informational responses must leave negotiation open for+ the final response, body-forbidden statuses must not gain compression+ framing, and once a body-permitted successful response advertises gzip, an+ explicit empty body must still emit a valid empty gzip member. Regression+ proof lives in `pkg/server/gzip_middleware_test.go`.WebSocket state refreshes on monitor, agent-report, and alert mutation hotpaths must enqueue coalesced current-state invalidations instead of buildingfull frontend-state payloads at every signal. The hub owns delayed@@ -1014,8 +1016,9 @@ supports wildcard acceptance, applies strict three-digit qvalue parsing, andlets explicit gzip exclusions override wildcards. WebSocket token lists andrange requests bypass the wrapper. Explicit empty 200 responses carry a validempty gzip stream whenever `Content-Encoding: gzip` is committed, while-204/304, SSE, already encoded, small declared, and binary responses stay on-their identity paths.+informational responses defer negotiation to the final response and 204/205/304,+SSE, already encoded, small declared, and binary responses stay on their+identity paths.### Libvirt workload projection stays bounded and allocation-localdiff --git a/pkg/server/gzip_middleware.go b/pkg/server/gzip_middleware.goindex f4d31cf276..0d4ae01378 100644--- a/pkg/server/gzip_middleware.go+++ b/pkg/server/gzip_middleware.go@@ -169,7 +169,10 @@ type gzipResponseWriter struct {}func (w *gzipResponseWriter) decide(status int) {- if w.decided {+ if w.decided || status >= 100 && status < 200 {+ // Informational responses do not select the representation for the final+ // response. Keep the decision open so a later 2xx-5xx status can use the+ // headers and body semantics the handler establishes for that response.return}w.decided = true@@ -177,7 +180,7 @@ func (w *gzipResponseWriter) decide(status int) {header := w.Header()header.Add("Vary", "Accept-Encoding")- if status == http.StatusNoContent || status == http.StatusNotModified {+ if status == http.StatusNoContent || status == http.StatusResetContent || status == http.StatusNotModified {return}if header.Get("Content-Encoding") != "" {diff --git a/pkg/server/gzip_middleware_test.go b/pkg/server/gzip_middleware_test.goindex 4e6c5d8d1c..76422525ac 100644--- a/pkg/server/gzip_middleware_test.go+++ b/pkg/server/gzip_middleware_test.go@@ -8,6 +8,8 @@ import ("net""net/http""net/http/httptest"+ "net/http/httptrace"+ "net/textproto""strconv""strings""testing"@@ -327,24 +329,76 @@ func TestWithGzipFlushOnEventStreamStaysIdentity(t *testing.T) {}func TestWithGzipPreservesStatusAndEmptyBodies(t *testing.T) {+ for _, status := range []int{+ http.StatusNoContent,+ http.StatusResetContent,+ http.StatusNotModified,+ } {+ t.Run(http.StatusText(status), func(t *testing.T) {+ handler := withGzip(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.Header().Set("Content-Type", "application/json")+ w.WriteHeader(status)+ }))++ req := httptest.NewRequest(http.MethodDelete, "/api/thing", nil)+ req.Header.Set("Accept-Encoding", "gzip")+ rec := httptest.NewRecorder()+ handler.ServeHTTP(rec, req)++ if rec.Code != status {+ t.Fatalf("status = %d, want %d", rec.Code, status)+ }+ if got := rec.Header().Get("Content-Encoding"); got != "" {+ t.Fatalf("Content-Encoding = %q, want empty for %d", got, status)+ }+ if rec.Body.Len() != 0 {+ t.Fatalf("%d grew a %d-byte body", status, rec.Body.Len())+ }+ })+ }+}++func TestWithGzipDefersDecisionPastInformationalResponse(t *testing.T) {+ payload := strings.Repeat(`{"status":"ready"}`, 256)handler := withGzip(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusEarlyHints)w.Header().Set("Content-Type", "application/json")- w.WriteHeader(http.StatusNoContent)+ w.WriteHeader(http.StatusOK)+ _, _ = w.Write([]byte(payload))}))+ server := httptest.NewServer(handler)+ defer server.Close()- req := httptest.NewRequest(http.MethodDelete, "/api/thing", nil)- req.Header.Set("Accept-Encoding", "gzip")- rec := httptest.NewRecorder()- handler.ServeHTTP(rec, req)+ request, err := http.NewRequest(http.MethodGet, server.URL, nil)+ if err != nil {+ t.Fatalf("build request: %v", err)+ }+ request.Header.Set("Accept-Encoding", "gzip")+ var informationalStatuses []int+ request = request.WithContext(httptrace.WithClientTrace(request.Context(), &httptrace.ClientTrace{+ Got1xxResponse: func(code int, _ textproto.MIMEHeader) error {+ informationalStatuses = append(informationalStatuses, code)+ return nil+ },+ }))+ client := &http.Client{Transport: &http.Transport{DisableCompression: true}}+ response, err := client.Do(request)+ if err != nil {+ t.Fatalf("request: %v", err)+ }+ defer response.Body.Close()- if rec.Code != http.StatusNoContent {- t.Fatalf("status = %d, want 204", rec.Code)+ if len(informationalStatuses) != 1 || informationalStatuses[0] != http.StatusEarlyHints {+ t.Fatalf("informational statuses = %v, want [103]", informationalStatuses)}- if got := rec.Header().Get("Content-Encoding"); got != "" {- t.Fatalf("Content-Encoding = %q, want empty for 204", got)+ if response.StatusCode != http.StatusOK {+ t.Fatalf("status = %d, want 200", response.StatusCode)+ }+ if got := response.Header.Get("Content-Encoding"); got != "gzip" {+ t.Fatalf("Content-Encoding = %q, want gzip on final response", got)}- if rec.Body.Len() != 0 {- t.Fatalf("204 grew a %d-byte body", rec.Body.Len())+ if decoded := gunzipBody(t, response.Body); decoded != payload {+ t.Fatalf("decompressed body does not match payload")}}