Skip to content

Commit

Permalink
XHTTP client: Fix upload issue in "packet-up" mode inherited from Spl…
Browse files Browse the repository at this point in the history
…itHTTP

Fixes XTLS#3972
  • Loading branch information
RPRX authored Nov 17, 2024
1 parent ec1fd00 commit 2d7b0e8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions transport/internet/splithttp/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// code relies on this behavior. Subtract 1 so that together with
// 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{
uploadPipeWriter,
Expand Down Expand Up @@ -400,10 +401,12 @@ type uploadWriter struct {
}

func (w uploadWriter) Write(b []byte) (int, error) {
capacity := int(w.maxLen - w.Len())
if capacity > 0 && capacity < len(b) {
b = b[:capacity]
}
/*
capacity := int(w.maxLen - w.Len())
if capacity > 0 && capacity < len(b) {
b = b[:capacity]
}
*/

buffer := buf.New()
n, err := buffer.Write(b)
Expand Down

0 comments on commit 2d7b0e8

Please sign in to comment.