Open
Description
Part of client code is like this
https://github.com/go-openapi/runtime/blob/master/client/runtime.go#L297
res, err := r.do(ctx, client, req) // make requests, by default follows 10 redirects before failing
if err != nil {
return nil, err
}
defer res.Body.Close()
if r.Debug {
b, err2 := httputil.DumpResponse(res, true)
if err2 != nil {
return nil, err2
}
r.logger.Debugf("%s\n", string(b))
}
With flag DEBUG=true
, ioutil.nopCloser
returned and consumer can unwrap ClientResponse.Body()
to check for validation error message like this "{\"code\":602,\"message\":\"name in body is required\"}"
.
For client in production environment and I don't want DEBUG
flag on, response body is closed, http.bodyEOFSignal
returned and can't do nothing to check for validation error.
Maybe there's option to retain response body or turn response body into ioutil.nopCloser
like httputil.DumpResponse
did ?