MCPcopy
hub / github.com/gofiber/fiber / Test_App_ServerErrorHandler_SmallReadBuffer

Function Test_App_ServerErrorHandler_SmallReadBuffer

app_test.go:410–430  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

408}
409
410func Test_App_ServerErrorHandler_SmallReadBuffer(t *testing.T) {
411 t.Parallel()
412 expectedError := regexp.MustCompile(
413 `error when reading request headers: small read buffer\. Increase ReadBufferSize\. Buffer size=4096, contents: "GET / HTTP/1.1\\r\\nHost: example\.com\\r\\nVery-Long-Header: -+`,
414 )
415 app := New()
416
417 app.Get("/", func(_ Ctx) error {
418 panic(errors.New("should never called"))
419 })
420
421 request := httptest.NewRequest(MethodGet, "/", http.NoBody)
422 logHeaderSlice := make([]string, 5000)
423 request.Header.Set("Very-Long-Header", strings.Join(logHeaderSlice, "-"))
424 _, err := app.Test(request)
425 if err == nil {
426 t.Error("Expect an error at app.Test(request)")
427 }
428
429 require.Regexp(t, expectedError, err.Error())
430}
431
432func Test_App_Errors(t *testing.T) {
433 t.Parallel()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
NewMethod · 0.65
SetMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected