Home / Function/ Test_HeaderContainsValue() — fiber Function Reference

Test_HeaderContainsValue() — fiber Function Reference

Architecture documentation for the Test_HeaderContainsValue() function in helpers_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  a0d009c7_6e87_c327_c1fc_bcdc5bcd1cd7["Test_HeaderContainsValue()"]
  c82e3595_b1b8_f596_c097_f26fa40159d1["helpers_test.go"]
  a0d009c7_6e87_c327_c1fc_bcdc5bcd1cd7 -->|defined in| c82e3595_b1b8_f596_c097_f26fa40159d1
  style a0d009c7_6e87_c327_c1fc_bcdc5bcd1cd7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

helpers_test.go lines 818–857

func Test_HeaderContainsValue(t *testing.T) {
	t.Parallel()
	testCases := []struct {
		header   string
		value    string
		expected bool
	}{
		// Exact match
		{header: "gzip", value: "gzip", expected: true},
		{header: "gzip", value: "deflate", expected: false},
		// Prefix match (value at start with comma)
		{header: "gzip, deflate", value: "gzip", expected: true},
		{header: "gzip,deflate", value: "gzip", expected: true},
		// Suffix match (value at end)
		{header: "deflate, gzip", value: "gzip", expected: true},
		{header: "deflate,gzip", value: "gzip", expected: true}, // No space - OWS is optional per RFC 9110
		{header: "br, gzip", value: "gzip", expected: true},
		// Middle match (value in middle)
		{header: "deflate, gzip, br", value: "gzip", expected: true},
		{header: "deflate,gzip,br", value: "gzip", expected: true}, // No spaces - OWS is optional per RFC 9110
		// No match - similar but not equal
		{header: "gzip2", value: "gzip", expected: false},
		{header: "2gzip", value: "gzip", expected: false},
		{header: "gzip2, deflate", value: "gzip", expected: false},
		// Whitespace handling (OWS per RFC 9110)
		{header: "  gzip  ,  deflate  ", value: "gzip", expected: true},
		{header: "deflate,  gzip  ", value: "gzip", expected: true},
		// Empty cases
		{header: "", value: "gzip", expected: false},
		{header: "gzip", value: "", expected: false},
		{header: "", value: "", expected: false}, // Both empty - should return false
	}

	for _, tc := range testCases {
		result := headerContainsValue(tc.header, tc.value)
		require.Equal(t, tc.expected, result,
			"headerContainsValue(%q, %q) = %v, want %v",
			tc.header, tc.value, result, tc.expected)
	}
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_HeaderContainsValue() do?
Test_HeaderContainsValue() is a function in the fiber codebase, defined in helpers_test.go.
Where is Test_HeaderContainsValue() defined?
Test_HeaderContainsValue() is defined in helpers_test.go at line 818.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free