Skip to content

Commit

Permalink
细节修复
Browse files Browse the repository at this point in the history
  • Loading branch information
lixizan committed Nov 26, 2022
1 parent 149f0d5 commit b219c71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ func SetAfter(fn func(ctx context.Context, response *http.Response) (context.Con
}

func NewReadCloser(body io.ReadCloser) (*ReadCloser, error) {
defer body.Close()
var rc = &ReadCloser{Buffer: bytes.NewBuffer(nil)}
_, err := io.Copy(rc, body)
_ = body.Close()
return rc, err
}

type ReadCloser struct {
*bytes.Buffer
}

func (r ReadCloser) Read(p []byte) (n int, err error) {
func (r *ReadCloser) Read(p []byte) (n int, err error) {
return r.Buffer.Read(p)
}

func (r ReadCloser) Close() error {
func (r *ReadCloser) Close() error {
return nil
}
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (c *Request) Send(v interface{}) *Response {

// 执行请求后中间件
response.ctx, response.err = c.after(c.ctx, resp)
if c.err != nil {
if response.err != nil {
return response
}

Expand Down

0 comments on commit b219c71

Please sign in to comment.