MCPcopy
hub / github.com/minio/minio-go / xmlDecodeAndBody

Function xmlDecodeAndBody

api-error-response.go:109–117  ·  view source on GitHub ↗

xmlDecodeAndBody reads the whole body up to 1MB and tries to XML decode it into v. The body that was read and any error from reading or decoding is returned.

(bodyReader io.Reader, v interface{})

Source from the content-addressed store, hash-verified

107// tries to XML decode it into v.
108// The body that was read and any error from reading or decoding is returned.
109func xmlDecodeAndBody(bodyReader io.Reader, v interface{}) ([]byte, error) {
110 // read the whole body (up to 1MB)
111 const maxBodyLength = 1 << 20
112 body, err := io.ReadAll(io.LimitReader(bodyReader, maxBodyLength))
113 if err != nil {
114 return nil, err
115 }
116 return bytes.TrimSpace(body), xmlDecoder(bytes.NewReader(body), v)
117}
118
119// httpRespToErrorResponse returns a new encoded ErrorResponse
120// structure as error.

Callers 1

httpRespToErrorResponseFunction · 0.70

Calls 1

xmlDecoderFunction · 0.70

Tested by

no test coverage detected