timeout writer add hijack
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/zeromicro/go-zero/rest/internal/response"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -134,6 +135,30 @@ func TestTimeoutClientClosed(t *testing.T) {
|
|||||||
assert.Equal(t, statusClientClosedRequest, resp.Code)
|
assert.Equal(t, statusClientClosedRequest, resp.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTimeoutHijack(t *testing.T) {
|
||||||
|
resp := httptest.NewRecorder()
|
||||||
|
|
||||||
|
writer := &timeoutWriter{
|
||||||
|
w: &response.WithCodeResponseWriter{
|
||||||
|
Writer: resp,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotPanics(t, func() {
|
||||||
|
writer.Hijack()
|
||||||
|
})
|
||||||
|
|
||||||
|
writer = &timeoutWriter{
|
||||||
|
w: &response.WithCodeResponseWriter{
|
||||||
|
Writer: mockedHijackable{resp},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotPanics(t, func() {
|
||||||
|
writer.Hijack()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestTimeoutPusher(t *testing.T) {
|
func TestTimeoutPusher(t *testing.T) {
|
||||||
handler := &timeoutWriter{
|
handler := &timeoutWriter{
|
||||||
w: mockedPusher{},
|
w: mockedPusher{},
|
||||||
|
|||||||
Reference in New Issue
Block a user