We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e482896 commit 314d58aCopy full SHA for 314d58a
1 file changed
response.go
@@ -740,8 +740,8 @@ type lenReadSeeker interface {
740
741
type dummyReadCloser struct {
742
orig any // string or []byte
743
+ mu sync.Mutex // protects operations over body
744
body lenReadSeeker // instanciated on demand from orig
- mu sync.Mutex
745
}
746
747
// copy returns a new instance resetting d.body to nil.
@@ -767,6 +767,9 @@ func (d *dummyReadCloser) setup() {
767
768
769
func (d *dummyReadCloser) Read(p []byte) (n int, err error) {
770
+ d.mu.Lock()
771
+ defer d.mu.Unlock()
772
+
773
d.setup()
774
return d.body.Read(p)
775
@@ -781,6 +784,9 @@ func (d *dummyReadCloser) Close() error {
781
784
782
785
783
786
func (d *dummyReadCloser) Len() int {
787
788
789
790
791
return d.body.Len()
792
0 commit comments