func FromHttpResponse(resp *http.Response) (Response, error) {
	newResp := NewResponse(resp.StatusCode, nil, "", getHeadersFromResponse(resp))

	if resp.Body != nil {
		responseBody, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return Response{}, err
		}
		newResp.Body = responseBody
	}

	if newResp.Status >= http.StatusMovedPermanently && newResp.Status <= http.StatusPermanentRedirect {
		redirectUri, err := resp.Location()
		if redirectUri != nil && err == nil {
			newResp.RedirectURL = redirectUri.String()
		}
	}

	return newResp, nil
}
// FromHttpResponse returns a new response based on the provided http response. Note that it is the caller's duty to close the body.
FromHttpResponse returns a new response based on the provided http response. Note that it is the caller's duty to close the body.
// FromHttpResponse returns a new response based on the provided http response . Note that it is the caller ' s duty to close the body .
func FromHttpResponse(resp *http.Response) (Response, error) {
	newResp := NewResponse(resp.StatusCode, nil, "", getHeadersFromResponse(resp))
	if resp.Body != nil {
		responseBody, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return Response{}, err
		}
		newResp.Body = responseBody
	}
	if newResp.Status >= http.StatusMovedPermanently && newResp.Status <= http.StatusPermanentRedirect {
		redirectUri, err := resp.Location()
		if redirectUri != nil && err == nil {
			newResp.RedirectURL = redirectUri.String()
		}
	}
	return newResp, nil
}
func FromHttpResponse ( resp * http . Response ) ( Response , error ) { newResp := NewResponse ( resp . StatusCode , nil , " " , getHeadersFromResponse ( resp ) ) if resp . Body != nil { responseBody , err := ioutil . ReadAll ( resp . Body ) if err != nil { return Response { } , err } newResp . Body = responseBody } if newResp . Status >= http . StatusMovedPermanently && newResp . Status <= http . StatusPermanentRedirect { redirectUri , err := resp . Location ( ) if redirectUri != nil && err == nil { newResp . RedirectURL = redirectUri . String ( ) } } return newResp , nil }
FromHttpResponse returns a new response based on the provided http response.
FromHttpResponse returns a new response based on the provided http response .