Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions common/httpx/wave10_canonical_headers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package httpx

import (
"net/http"
"testing"
)

func TestWave10HeaderCanonicalization(t *testing.T) {
headers := http.Header{}
headers.Add("x-bountygrid-trace", "bg-titan-wave10")
headers.Add("content-type", "application/json")

val := headers.Get("X-BountyGrid-Trace")
if val != "bg-titan-wave10" {
t.Errorf("expected canonical header lookup to match case-insensitively, got %s", val)
}

ct := headers.Get("Content-Type")
if ct != "application/json" {
t.Errorf("expected canonical Content-Type lookup to match, got %s", ct)
}
}

func TestWave10StatusCodeClassification(t *testing.T) {
isSuccess := func(code int) bool {
return code >= 200 && code < 300
}
isRedirect := func(code int) bool {
return code >= 300 && code < 400
}

if !isSuccess(200) || !isSuccess(204) {
t.Errorf("expected 200/204 to be classified as success")
}
if !isRedirect(301) || !isRedirect(308) {
t.Errorf("expected 301/308 to be classified as redirect")
}
}