Skip to content

Commit a2aa72c

Browse files
committed
chore(binding): improved Body.Close
Change-Id: I7973ed3f7a2e47f6aa91575272e387bb7df87c6c
1 parent cb84d6c commit a2aa72c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

binding/body.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ type Body struct {
3838
}
3939

4040
// Close close.
41-
func (Body) Close() error { return nil }
41+
func (b *Body) Close() error {
42+
b.Buffer = nil
43+
b.bodyBytes = nil
44+
return nil
45+
}
4246

4347
// Reset zero offset.
4448
func (b *Body) Reset() {

binding/body_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ func TestBody(t *testing.T) {
4040
b, err = ioutil.ReadAll(body)
4141
assert.NoError(t, err)
4242
assert.Equal(t, []byte("abc"), b)
43+
body.Close()
44+
assert.Equal(t, []byte(nil), body.Bytes())
4345
}

0 commit comments

Comments
 (0)