File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -140,20 +140,22 @@ func (r *Request) close() error {
140
140
}()
141
141
142
142
r .state .RLock ()
143
- rd := r .state .readerAt
144
143
wr := r .state .writerAt
144
+ rd := r .state .readerAt
145
145
r .state .RUnlock ()
146
146
147
147
var err error
148
148
149
- if c , ok := rd .(io.Closer ); ok {
149
+ // Close errors on a Writer are far more likely to be the important one.
150
+ // As they can be information that there was a loss of data.
151
+ if c , ok := wr .(io.Closer ); ok {
150
152
if err2 := c .Close (); err == nil {
151
153
// update error if it is still nil
152
154
err = err2
153
155
}
154
156
}
155
157
156
- if c , ok := wr .(io.Closer ); ok {
158
+ if c , ok := rd .(io.Closer ); ok {
157
159
if err2 := c .Close (); err == nil {
158
160
// update error if it is still nil
159
161
err = err2
@@ -170,15 +172,15 @@ func (r *Request) transferError(err error) {
170
172
}
171
173
172
174
r .state .RLock ()
173
- rd := r .state .readerAt
174
175
wr := r .state .writerAt
176
+ rd := r .state .readerAt
175
177
r .state .RUnlock ()
176
178
177
- if t , ok := rd .(TransferError ); ok {
179
+ if t , ok := wr .(TransferError ); ok {
178
180
t .TransferError (err )
179
181
}
180
182
181
- if t , ok := wr .(TransferError ); ok {
183
+ if t , ok := rd .(TransferError ); ok {
182
184
t .TransferError (err )
183
185
}
184
186
}
You can’t perform that action at this time.
0 commit comments