MCPcopy
hub / github.com/valyala/fasthttp / TestRequestHeaderFirstLineSettersSanitizeNewlines

Function TestRequestHeaderFirstLineSettersSanitizeNewlines

header_test.go:2804–2904  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2802}
2803
2804func TestRequestHeaderFirstLineSettersSanitizeNewlines(t *testing.T) {
2805 t.Parallel()
2806
2807 testCases := []struct {
2808 name string
2809 set func(*RequestHeader)
2810 value func(*RequestHeader) []byte
2811 wantValue string
2812 wantFirstLine string
2813 wantNoHTTP11 bool
2814 }{
2815 {
2816 name: "SetMethod",
2817 set: func(h *RequestHeader) {
2818 h.SetMethod("GET\r\nInjected-Method: true")
2819 },
2820 value: func(h *RequestHeader) []byte { return h.Method() },
2821 wantValue: "GET Injected-Method: true",
2822 wantFirstLine: "GET Injected-Method: true / HTTP/1.1",
2823 },
2824 {
2825 name: "SetMethodBytes",
2826 set: func(h *RequestHeader) {
2827 h.SetMethodBytes([]byte("GET\r\nInjected-Method-Bytes: true"))
2828 },
2829 value: func(h *RequestHeader) []byte { return h.Method() },
2830 wantValue: "GET Injected-Method-Bytes: true",
2831 wantFirstLine: "GET Injected-Method-Bytes: true / HTTP/1.1",
2832 },
2833 {
2834 name: "SetRequestURI",
2835 set: func(h *RequestHeader) {
2836 h.SetRequestURI("/\r\nInjected-URI: true")
2837 },
2838 value: func(h *RequestHeader) []byte { return h.RequestURI() },
2839 wantValue: "/ Injected-URI: true",
2840 wantFirstLine: "GET / Injected-URI: true HTTP/1.1",
2841 },
2842 {
2843 name: "SetRequestURIBytes",
2844 set: func(h *RequestHeader) {
2845 h.SetRequestURIBytes([]byte("/\r\nInjected-URI-Bytes: true"))
2846 },
2847 value: func(h *RequestHeader) []byte { return h.RequestURI() },
2848 wantValue: "/ Injected-URI-Bytes: true",
2849 wantFirstLine: "GET / Injected-URI-Bytes: true HTTP/1.1",
2850 },
2851 {
2852 name: "SetProtocol",
2853 set: func(h *RequestHeader) {
2854 h.SetProtocol("HTTP/1.1\r\nInjected-Protocol: true")
2855 },
2856 value: func(h *RequestHeader) []byte { return h.Protocol() },
2857 wantValue: "HTTP/1.1 Injected-Protocol: true",
2858 wantFirstLine: "GET / HTTP/1.1 Injected-Protocol: true",
2859 wantNoHTTP11: true,
2860 },
2861 {

Callers

nothing calls this directly

Calls 11

SetMethodMethod · 0.95
MethodMethod · 0.95
SetMethodBytesMethod · 0.95
SetRequestURIMethod · 0.95
RequestURIMethod · 0.95
SetRequestURIBytesMethod · 0.95
SetProtocolMethod · 0.95
SetProtocolBytesMethod · 0.95
SetHostMethod · 0.95
HeaderMethod · 0.95
ProtocolMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…