mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-21 20:29:19 +02:00
XHTTP client: Fix upload issue in "packet-up" mode inherited from SplitHTTP
Fixes https://github.com/XTLS/Xray-core/issues/3972
This commit is contained in:
parent
ec1fd008c4
commit
2d7b0e8cd4
|
@ -324,7 +324,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||||
// WithSizeLimit(0) will still allow single bytes to pass, and a lot of
|
// WithSizeLimit(0) will still allow single bytes to pass, and a lot of
|
||||||
// code relies on this behavior. Subtract 1 so that together with
|
// code relies on this behavior. Subtract 1 so that together with
|
||||||
// uploadWriter wrapper, exact size limits can be enforced
|
// uploadWriter wrapper, exact size limits can be enforced
|
||||||
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1))
|
// uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1))
|
||||||
|
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - buf.Size))
|
||||||
|
|
||||||
conn.writer = uploadWriter{
|
conn.writer = uploadWriter{
|
||||||
uploadPipeWriter,
|
uploadPipeWriter,
|
||||||
|
@ -400,10 +401,12 @@ type uploadWriter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w uploadWriter) Write(b []byte) (int, error) {
|
func (w uploadWriter) Write(b []byte) (int, error) {
|
||||||
capacity := int(w.maxLen - w.Len())
|
/*
|
||||||
if capacity > 0 && capacity < len(b) {
|
capacity := int(w.maxLen - w.Len())
|
||||||
b = b[:capacity]
|
if capacity > 0 && capacity < len(b) {
|
||||||
}
|
b = b[:capacity]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
buffer := buf.New()
|
buffer := buf.New()
|
||||||
n, err := buffer.Write(b)
|
n, err := buffer.Write(b)
|
||||||
|
|
Loading…
Reference in New Issue