MCPcopy Index your code
hub / github.com/keploy/keploy / TestToHTTPHeader_AcceptListValue_FoldedSingleHeader

Function TestToHTTPHeader_AcceptListValue_FoldedSingleHeader

pkg/util_test.go:890–903  ·  view source on GitHub ↗

TestToHTTPHeader_AcceptListValue_FoldedSingleHeader pins the wire behaviour that the duplicate-Accept TypeError fix depends on: an axios-style `Accept: application/json, text/plain, */*` mock must replay as ONE wire header so server middlewares using `dict(**request.headers)` do not see duplicate `a

(t *testing.T)

Source from the content-addressed store, hash-verified

888// replay as ONE wire header so server middlewares using
889// `dict(**request.headers)` do not see duplicate `accept` keys.
890func TestToHTTPHeader_AcceptListValue_FoldedSingleHeader(t *testing.T) {
891 mockHeader := map[string]string{
892 "Accept": "application/json, text/plain, */*",
893 "Accept-Encoding": "gzip, compress, deflate, br",
894 "Baggage": "trace-id=abc,user-key=def,env=test",
895 }
896 httpHeader := ToHTTPHeader(mockHeader)
897 require.Len(t, httpHeader["Accept"], 1, "Accept must replay as one wire header")
898 require.Len(t, httpHeader["Accept-Encoding"], 1, "Accept-Encoding must replay as one wire header")
899 require.Len(t, httpHeader["Baggage"], 1, "Baggage must replay as one wire header")
900 assert.Equal(t, "application/json, text/plain, */*", httpHeader["Accept"][0])
901 assert.Equal(t, "gzip, compress, deflate, br", httpHeader["Accept-Encoding"][0])
902 assert.Equal(t, "trace-id=abc,user-key=def,env=test", httpHeader["Baggage"][0])
903}
904
905// TestParseHTTPRequest_And_Response_111 contains sub-tests for ParseHTTPRequest and
906// ParseHTTPResponse, validating both success and failure cases for parsing raw

Callers

nothing calls this directly

Calls 1

ToHTTPHeaderFunction · 0.85

Tested by

no test coverage detected