// readBody reads the http.Response body and assigns it to the r.Body
readBody reads the http.Response body and assigns it to the r.Body
// readBody reads the http . Response body and assigns it to the r . Body
func (r *Response) readBody() ([]byte, error) {
	if len(r.data) != 0 {
		return r.data, nil
	}
	if r.resp == nil {
		err := fmt.Errorf("http.Response is nil")
		logger.Errorf("%v", err)
		return nil, err
	}
	if r.resp.Body == nil {
		err := fmt.Errorf("http.Response's Body is nil")
		logger.Errorf("%v", err)
		return nil, err
	}
	b, err := ioutil.ReadAll(r.resp.Body)
	if err != nil {
		logger.Errorf("Can't read http.Response body Error: %v", err)
		return nil, err
	}
	r.data = b
	err = r.resp.Body.Close()
	if err != nil {
		logger.Errorf("Can't close http.Response body Error: %v", err)
		return nil, err
	}
	return b, nil
}
func ( r * Response ) readBody ( ) ( [ ] byte , error ) { if len ( r . data ) != 0 { return r . data , nil } if r . resp == nil { err := fmt . Errorf ( " " ) logger . Errorf ( " " , err ) return nil , err } if r . resp . Body == nil { err := fmt . Errorf ( " " ) logger . Errorf ( " " , err ) return nil , err } b , err := ioutil . ReadAll ( r . resp . Body ) if err != nil { logger . Errorf ( " " , err ) return nil , err } r . data = b err = r . resp . Body . Close ( ) if err != nil { logger . Errorf ( " " , err ) return nil , err } return b , nil }
readBody reads the http.Response body and assigns it to the r.Body
readBody reads the http . Response body and assigns it to the r . Body
// If r.data already set then return r.data // Check if Response.resp (*http.Response) is nil // Check if Response.resp.Body (*http.Response.Body) is nil // Read response body // Set response readBody // Close response body