mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
make sure writer not buffered
This commit is contained in:
parent
5a6022d1ed
commit
f3c5df8798
@ -121,6 +121,7 @@ func (w *BufferedWriter) SetBuffered(f bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadFrom implements io.ReaderFrom.
|
||||
func (w *BufferedWriter) ReadFrom(reader io.Reader) (int64, error) {
|
||||
var sc SizeCounter
|
||||
if !w.buffer.IsEmpty() {
|
||||
@ -130,11 +131,12 @@ func (w *BufferedWriter) ReadFrom(reader io.Reader) (int64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
w.buffered = false
|
||||
|
||||
if readerFrom, ok := w.writer.(io.ReaderFrom); ok {
|
||||
return readerFrom.ReadFrom(reader)
|
||||
}
|
||||
|
||||
w.buffered = false
|
||||
err := Copy(NewReader(reader), w, CountSize(&sc))
|
||||
return sc.Size, err
|
||||
}
|
||||
|
@ -257,13 +257,8 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
|
||||
request.Header.Set("Connection", "close")
|
||||
|
||||
requestWriter := buf.NewBufferedWriter(ray.InboundInput())
|
||||
if err := request.Write(requestWriter); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := requestWriter.Flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
common.Must(requestWriter.SetBuffered(false))
|
||||
return request.Write(requestWriter)
|
||||
})
|
||||
|
||||
responseDone := signal.ExecuteAsync(func() error {
|
||||
|
Loading…
Reference in New Issue
Block a user