(t *testing.T)
| 2151 | } |
| 2152 | |
| 2153 | func TestServerRejectsMissingHostHTTP11(t *testing.T) { |
| 2154 | t.Parallel() |
| 2155 | |
| 2156 | var handlerCalled atomic.Bool |
| 2157 | s := &Server{ |
| 2158 | Handler: func(ctx *RequestCtx) { |
| 2159 | handlerCalled.Store(true) |
| 2160 | ctx.Success("text/plain", []byte("ok")) |
| 2161 | }, |
| 2162 | } |
| 2163 | |
| 2164 | rw := &readWriter{} |
| 2165 | rw.r.WriteString("GET /foo HTTP/1.1\r\n\r\n") |
| 2166 | |
| 2167 | _ = s.ServeConn(rw) |
| 2168 | |
| 2169 | br := bufio.NewReader(&rw.w) |
| 2170 | verifyResponse(t, br, StatusBadRequest, string(defaultContentType), "Error when parsing request") |
| 2171 | |
| 2172 | if handlerCalled.Load() { |
| 2173 | t.Fatal("handler should not run for HTTP/1.1 request without Host") |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | func TestServerRejectsInvalidContentLengthWithTransferEncoding(t *testing.T) { |
| 2178 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…