18 Commits

Author SHA1 Message Date
Bo-Yi Wu
234a6d4c00
fix(response): refine hijack behavior for response lifecycle (#4373)
* 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>
2025-09-26 08:13:39 +08:00
諏訪原慶斗
32065bbd42
chore(response): prevention of Hijack() runtime panics (#4295)
* Prevention of Hijack() runtime panics

* added test of Hijack()

* fix review

* fix lint error

* added check assertion of Wrrten() condition before calling Hijack()
2025-08-02 12:16:58 +08:00
Matthieu MOREL
5f55c6a711
ci(lint): enable testifylint linter (#4010)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-07-14 20:33:08 +08:00
Leonardo de Araujo
bb2d8cf486
test(render): increased unit tests coverage (#3691) 2023-08-12 22:21:56 +08:00
David Desmarais-Michaud
c1d06e3d08
add supprt for go1.20 http.rwUnwrapper to gin.responseWriter (#3489) 2023-02-12 13:01:43 +08:00
Alireza (Pure)
41f2669ebc
console logger HTTP status bug fixed and the corresponding unit test added (#3453) 2023-01-02 11:38:53 +08:00
thinkerou
4b68a5f12a
chore: update go.mod and remove space from copyright (#3158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-28 10:42:28 +08:00
Matthieu MOREL
435a76b735
chore(ci): update dependencies (#2827)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
2021-08-19 15:46:31 +08:00
John Bampton
beb879e475 Change Writter to Writer. (#2079) 2019-09-30 14:22:12 +08:00
Dmitry Kutakov
b056a34bdc fix errcheck warnings (#1739) 2019-01-18 09:32:53 +08:00
田欧
f45c928a15 chore: use http.Status* instead of hard code (#1482) 2018-08-14 09:51:56 +08:00
zhanweidu
0552c3bc3a flush operation will overwrite the origin status code (#1460)
The status of responseWriter will be overwrite if flush was called. This is caused by the Flush of http.response.Flush().
2018-08-07 12:41:28 +08:00
vz
d17a12591f update assert param(expect, actual) position (#1421)
- update assert param(expect, actual) position
2018-07-03 15:39:18 +08:00
Eason Lin
81007d2ce0 refactor(test): unify assert.Equal usage (#1054) 2017-08-04 13:45:59 +08:00
Manu Mtz-Almeida
0cb52ccef7 Improves unit test coverage 2015-05-19 02:29:32 +02:00
Manu Mtz-Almeida
0a192fb0fa Tons of unit tests 2015-04-09 12:15:02 +02:00
Manu Mtz-Almeida
c61c547539 More unit tests for ResponseWriter 2015-04-08 15:20:39 +02:00
Manu Mtz-Almeida
4d315f474b More unit tests 2015-04-08 14:24:49 +02:00