MCPcopy
hub / github.com/cloudfoundry/cli / populateResponse

Method populateResponse

api/plugin/plugin_connection.go:73–98  ·  view source on GitHub ↗
(response *http.Response, passedResponse *Response, body io.ReadCloser)

Source from the content-addressed store, hash-verified

71}
72
73func (connection *PluginConnection) populateResponse(response *http.Response, passedResponse *Response, body io.ReadCloser) error {
74 passedResponse.HTTPResponse = response
75
76 rawBytes, err := io.ReadAll(body)
77 defer body.Close()
78 if err != nil {
79 return err
80 }
81 passedResponse.RawResponse = rawBytes
82
83 err = connection.handleStatusCodes(response, passedResponse)
84 if err != nil {
85 return err
86 }
87
88 if passedResponse.Result != nil {
89 decoder := json.NewDecoder(bytes.NewBuffer(passedResponse.RawResponse))
90 decoder.UseNumber()
91 err = decoder.Decode(passedResponse.Result)
92 if err != nil {
93 return err
94 }
95 }
96
97 return nil
98}
99
100// processRequestError handles errors that occur while making the request.
101func (connection *PluginConnection) processRequestErrors(request *http.Request, err error) error {

Callers 1

MakeMethod · 0.95

Calls 2

handleStatusCodesMethod · 0.95
CloseMethod · 0.65

Tested by

no test coverage detected