mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
make the responseWriter hijackable
This commit is contained in:
parent
a983db0301
commit
ff6313fdb3
4 changed files with 13 additions and 6 deletions
|
@ -23,6 +23,7 @@ type DataStreamer interface {
|
|||
}
|
||||
|
||||
type responseWriter struct {
|
||||
conn quic.Connection
|
||||
stream quic.Stream // needed for DataStream()
|
||||
bufferedStream *bufio.Writer
|
||||
|
||||
|
@ -38,12 +39,14 @@ var (
|
|||
_ http.ResponseWriter = &responseWriter{}
|
||||
_ http.Flusher = &responseWriter{}
|
||||
_ DataStreamer = &responseWriter{}
|
||||
_ Hijacker = &responseWriter{}
|
||||
)
|
||||
|
||||
func newResponseWriter(stream quic.Stream, logger utils.Logger) *responseWriter {
|
||||
func newResponseWriter(stream quic.Stream, conn quic.Connection, logger utils.Logger) *responseWriter {
|
||||
return &responseWriter{
|
||||
header: http.Header{},
|
||||
stream: stream,
|
||||
conn: conn,
|
||||
bufferedStream: bufio.NewWriter(stream),
|
||||
logger: logger,
|
||||
}
|
||||
|
@ -123,6 +126,10 @@ func (w *responseWriter) StreamID() quic.StreamID {
|
|||
return w.stream.StreamID()
|
||||
}
|
||||
|
||||
func (w *responseWriter) StreamCreator() StreamCreator {
|
||||
return w.conn
|
||||
}
|
||||
|
||||
// copied from http2/http2.go
|
||||
// bodyAllowedForStatus reports whether a given response status code
|
||||
// permits a body. See RFC 2616, section 4.4.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue