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

Function TestServerRejectsMissingHostHTTP11

server_test.go:2153–2175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2151}
2152
2153func 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
2177func TestServerRejectsInvalidContentLengthWithTransferEncoding(t *testing.T) {
2178 t.Parallel()

Callers

nothing calls this directly

Calls 5

ServeConnMethod · 0.95
verifyResponseFunction · 0.85
SuccessMethod · 0.80
NewReaderMethod · 0.80
WriteStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…