TestToHTTPHeader_WithTimeValue_909 verifies that the ToHTTPHeader function correctly converts a map of strings to an http.Header object. It specifically checks that header values recognized as timestamps are not split by commas, while other comma-separated values are correctly split into slices.
(t *testing.T)
| 861 | // header values recognized as timestamps are not split by commas, while other |
| 862 | // comma-separated values are correctly split into slices. |
| 863 | func TestToHTTPHeader_WithTimeValue_909(t *testing.T) { |
| 864 | // Arrange |
| 865 | mockHeader := map[string]string{ |
| 866 | "Date": "Tue, 17 Jan 2023 16:34:58 IST", |
| 867 | "X-Custom-Header": "value1,value2", |
| 868 | "Content-Type": "application/json", |
| 869 | } |
| 870 | |
| 871 | // Act |
| 872 | httpHeader := ToHTTPHeader(mockHeader) |
| 873 | |
| 874 | // Assert: every YAML key replays as exactly one wire header. The |
| 875 | // recorded value is kept intact (commas included) so axios-style |
| 876 | // `Accept: a, b, c` does not fan out into three duplicate-name |
| 877 | // wire headers — see ToHTTPHeader's comment for why fan-out |
| 878 | // breaks `dict(**request.headers)`-style server middlewares. |
| 879 | require.NotNil(t, httpHeader) |
| 880 | assert.Equal(t, []string{"Tue, 17 Jan 2023 16:34:58 IST"}, httpHeader["Date"]) |
| 881 | assert.Equal(t, []string{"value1,value2"}, httpHeader["X-Custom-Header"]) |
| 882 | assert.Equal(t, []string{"application/json"}, httpHeader["Content-Type"]) |
| 883 | } |
| 884 | |
| 885 | // TestToHTTPHeader_AcceptListValue_FoldedSingleHeader pins the wire |
| 886 | // behaviour that the duplicate-Accept TypeError fix depends on: an |
nothing calls this directly
no test coverage detected