mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-12 16:48:19 +08:00
Compare commits
4 Commits
fc011cb505
...
2d32da23f8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d32da23f8 | ||
|
|
26c3a62865 | ||
|
|
22c274c84b | ||
|
|
44b40e45b4 |
2
.github/workflows/gin.yml
vendored
2
.github/workflows/gin.yml
vendored
@ -65,7 +65,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
${{ matrix.go-build }}
|
||||
|
||||
@ -117,7 +117,11 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
if w.size < 0 {
|
||||
w.size = 0
|
||||
}
|
||||
return w.ResponseWriter.(http.Hijacker).Hijack()
|
||||
hijacker, ok := w.ResponseWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("response writer does not support Hijack")
|
||||
}
|
||||
return hijacker.Hijack()
|
||||
}
|
||||
|
||||
// CloseNotify implements the http.CloseNotifier interface.
|
||||
@ -128,7 +132,9 @@ func (w *responseWriter) CloseNotify() <-chan bool {
|
||||
// Flush implements the http.Flusher interface.
|
||||
func (w *responseWriter) Flush() {
|
||||
w.WriteHeaderNow()
|
||||
w.ResponseWriter.(http.Flusher).Flush()
|
||||
if f, ok := w.ResponseWriter.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *responseWriter) Pusher() (pusher http.Pusher) {
|
||||
|
||||
@ -113,10 +113,8 @@ func TestResponseWriterHijack(t *testing.T) {
|
||||
writer.reset(testWriter)
|
||||
w := ResponseWriter(writer)
|
||||
|
||||
assert.Panics(t, func() {
|
||||
_, _, err := w.Hijack()
|
||||
require.NoError(t, err)
|
||||
})
|
||||
_, _, err := w.Hijack()
|
||||
assert.Equal(t, "response writer does not support Hijack", err.Error())
|
||||
assert.True(t, w.Written())
|
||||
|
||||
assert.Panics(t, func() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user