Wrapped response writers such as http.TimeoutHandler may not implement
Hijacker or CloseNotifier. Match the safe optional-interface checks used by
Flush and Pusher before calling through.
Tested: docker run --rm -v "$PWD":/src -w /src golang:1.25 go test -run 'TestResponseWriterHijack|TestResponseWriterHijackAfterWrite|TestResponseWriterHijackAfterWriteHeaderNow' ./...
Tested: docker run --rm -v "$PWD":/src -w /src golang:1.25 go test ./...
* feat: refine hijack behavior for response lifecycle and add tests
- Clarify the error message for attempted hijack after response body data is written
- Modify hijack behavior: allow hijacking after headers are written (for better websocket compatibility), but block hijacking after any body data is sent
- Add comprehensive tests to validate allowed hijack after header write and disallowed hijack after body write
fix https://github.com/gin-gonic/gin/issues/4372
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* test: use require for immediate test failure on errors
- Replace assert with require for error checks to ensure test failures immediately halt execution
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Update response_writer.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>