Test_FiberHandler_WithInterruptedSendStreamWriter() — fiber Function Reference
Architecture documentation for the Test_FiberHandler_WithInterruptedSendStreamWriter() function in adaptor_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 4dfa3220_b50b_63b5_dbb3_7cccd26cf180["Test_FiberHandler_WithInterruptedSendStreamWriter()"] 8ec96b38_44b4_af66_6f6f_dd60f87b680c["adaptor_test.go"] 4dfa3220_b50b_63b5_dbb3_7cccd26cf180 -->|defined in| 8ec96b38_44b4_af66_6f6f_dd60f87b680c style 4dfa3220_b50b_63b5_dbb3_7cccd26cf180 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/adaptor/adaptor_test.go lines 988–1031
func Test_FiberHandler_WithInterruptedSendStreamWriter(t *testing.T) {
t.Parallel()
// Test streaming functionality to ensure data is sent even during a timeout.
fiberH := func(c fiber.Ctx) error {
c.Status(fiber.StatusTeapot)
return c.SendStreamWriter(func(w *bufio.Writer) {
w.WriteString("Hello ") //nolint:errcheck // not needed
w.Flush() //nolint:errcheck // not needed
time.Sleep(500 * time.Millisecond) // Simulate a long operation
w.WriteString("World!") //nolint:errcheck // not needed
})
}
handlerFunc := FiberHandlerFunc(fiberH)
// Start a mock HTTP server using the handlerFunc
server := &http.Server{
Handler: handlerFunc,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
listener, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
require.NoError(t, err)
addr := fmt.Sprintf("http://%s", listener.Addr())
go func() {
server.Serve(listener) //nolint:errcheck // not needed
}()
defer func() {
require.NoError(t, server.Close())
}()
cc := &http.Client{
Timeout: 200 * time.Millisecond,
}
resp, err := cc.Get(addr) //nolint:noctx // ctx is not needed
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, fiber.StatusTeapot, resp.StatusCode)
body, readErr := io.ReadAll(resp.Body)
require.ErrorIs(t, readErr, context.DeadlineExceeded)
require.Equal(t, "Hello ", string(body))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_FiberHandler_WithInterruptedSendStreamWriter() do?
Test_FiberHandler_WithInterruptedSendStreamWriter() is a function in the fiber codebase, defined in middleware/adaptor/adaptor_test.go.
Where is Test_FiberHandler_WithInterruptedSendStreamWriter() defined?
Test_FiberHandler_WithInterruptedSendStreamWriter() is defined in middleware/adaptor/adaptor_test.go at line 988.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free