code: func (r *Request) transformResponse(resp *http.Response, req *http.Request) Result {
  	var body []byte
  	if resp.Body != nil {
  		if data, err := ioutil.ReadAll(resp.Body); err == nil {
  			body = data
  		}
  	}
  	glog.V(8).Infof("Response Body: %s", string(body))
  
  	// Did the server give us a status response?
  	isStatusResponse := false
  	var status unversioned.Status
  	if err := r.codec.DecodeInto(body, &status); err == nil && status.Status != "" {
  		isStatusResponse = true
  	}
  
  	switch {
  	case resp.StatusCode == http.StatusSwitchingProtocols:
  		// no-op, we've been upgraded
  	case resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent:
  		if !isStatusResponse {
  			return Result{err: r.transformUnstructuredResponseError(resp, req, body)}
  		}
  		return Result{err: errors.FromObject(&status)}
  	}
  
  	// If the server gave us a status back, look at what it was.
  	success := resp.StatusCode >= http.StatusOK && resp.StatusCode <= http.StatusPartialContent
  	if isStatusResponse && (status.Status != unversioned.StatusSuccess && !success) {
  		// "Failed" requests are clearly just an error and it makes sense to return them as such.
  		return Result{err: errors.FromObject(&status)}
  	}
  
  	return Result{
  		body:       body,
  		statusCode: resp.StatusCode,
  		codec:      r.codec,
  	}
  }
docs: // transformResponse converts an API response into a structured API object