Skip to content

Commit

Permalink
fix: call conn.release method in ext.ReleaseBodystream
Browse files Browse the repository at this point in the history
  • Loading branch information
Duslia committed Dec 24, 2024
1 parent 7d63572 commit b3eba17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/protocol/http1/ext/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ func (rs *bodyStream) skipRest() error {
if err != nil {
return err
}
err = rs.reader.Release()
if err != nil {
return err
}

}
}
// max value of pSize is 8193, it's safe.
Expand Down Expand Up @@ -300,7 +305,14 @@ func (rs *bodyStream) skipRest() error {
if skip > needSkipLen {
skip = needSkipLen
}
rs.reader.Skip(skip)
err := rs.reader.Skip(skip)
if err != nil {
return err
}
err = rs.reader.Release()
if err != nil {
return err
}
needSkipLen -= skip
if needSkipLen == 0 {
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/protocol/http1/req/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ func TestStreamNotEnoughData(t *testing.T) {
err = ext.ReleaseBodyStream(req.BodyStream())
assert.Nil(t, err)
assert.DeepEqual(t, 0, len(conn.Data))
assert.DeepEqual(t, true, conn.HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.19)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.18)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / code-cov

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.17)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.20)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.22)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.18)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / code-cov

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.19)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.23)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / compat-test (1.17)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.20)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / lint

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased) (typecheck)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.22)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.21)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / unit-test (1.23)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / ut-windows (1.20)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / ut-windows (1.23)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)

Check failure on line 1428 in pkg/protocol/http1/req/request_test.go

View workflow job for this annotation

GitHub Actions / ut-windows (1.21)

conn.HasReleased undefined (type *mock.StreamConn has no field or method HasReleased)
}

func TestRequestBodyStreamWithTrailer(t *testing.T) {
Expand Down

0 comments on commit b3eba17

Please sign in to comment.