From 9ac63eb5756ff67d80b24d2996fa088c14c58ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:26:16 +0300 Subject: [PATCH 1/2] be/int/web/reception/captured: fixes the status code representation built incorrectly after implicit body write. --- backend/internal/web/reception/captured/rw.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/internal/web/reception/captured/rw.go b/backend/internal/web/reception/captured/rw.go index acb1a28f..7da6c4bc 100644 --- a/backend/internal/web/reception/captured/rw.go +++ b/backend/internal/web/reception/captured/rw.go @@ -44,8 +44,8 @@ func (rw ResponseWriter) Status() (int, bool) { } func (rw ResponseWriter) StatusRepresentation() string { - if !rw.written { - return strconv.Itoa(rw.statusCode) + "*" + if rw.statusCode == 0 && rw.written { + return "200*" } return strconv.Itoa(rw.statusCode) } From e77a914fd8803774fac653a00f6bac81b2bd064f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:27:17 +0300 Subject: [PATCH 2/2] be/int/web/reception/captured: adds a test for #64 --- .../web/reception/captured/rw_test.go | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/backend/internal/web/reception/captured/rw_test.go b/backend/internal/web/reception/captured/rw_test.go index 8a369c1e..09091812 100644 --- a/backend/internal/web/reception/captured/rw_test.go +++ b/backend/internal/web/reception/captured/rw_test.go @@ -64,3 +64,29 @@ func TestResponseWriter_SizeRepresentation(t *testing.T) { t.Errorf("expected %q got %q", expected, got) } } + +func TestResponseWriter_statusCodeRepresentation(t *testing.T) { + t.Run("untouched", func(t *testing.T) { + w := New(httptest.NewRecorder()) + expected, got := "0", w.StatusRepresentation() + if expected != got { + t.Errorf("expected %q got %q", expected, got) + } + }) + t.Run("implicit", func(t *testing.T) { + w := New(httptest.NewRecorder()) + w.Write([]byte("lorem ipsum dolor sit amet.")) + expected, got := "200*", w.StatusRepresentation() + if expected != got { + t.Errorf("expected %q got %q", expected, got) + } + }) + t.Run("explicit", func(t *testing.T) { + w := New(httptest.NewRecorder()) + w.WriteHeader(200) + expected, got := "200", w.StatusRepresentation() + if expected != got { + t.Errorf("expected %q got %q", expected, got) + } + }) +}