// decodeBody is used to XML decode a response body
500318
func decodeBody(resp *http.Response, out interface{}) error {

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

	// Unmarshal the XML.
	if err = xml.Unmarshal(body, &out); err != nil {
		return err
	}

	return nil
}
1337397
func (remote *RemoteDebugger) GetResponseBody(req string) ([]byte, error) {
	res, err := remote.SendRequest("Network.getResponseBody", Params{
		"requestId": req,
	})

	if err != nil {
		return nil, err
	}

	body := res["body"]
	if body == nil {
		return nil, nil
	}

	if b, ok := res["base64Encoded"]; ok && b.(bool) {
		return base64.StdEncoding.DecodeString(body.(string))
	} else {
		return []byte(body.(string)), nil
	}
}
980476
func Body(r *http.Request, v interface{}) error {
	if err := json.NewDecoder(r.Body).Decode(v); err != nil {
		return err
	}
	return Validate.StructCtx(r.Context(), v)
}
263376
func (n *NewPullRequest) GetBody() string {
	if n == nil || n.Body == nil {
		return ""
	}
	return *n.Body
}
368312
func (p *PullRequestComment) GetBody() string {
	if p == nil || p.Body == nil {
		return ""
	}
	return *p.Body
}
1111569
func RequestBodyDecodeError(req *transport.Request, err error) error {
	return newServerEncodingError(req, nil, false /*isResponse*/, false /*isHeader*/, err)
}
846497
func (p *PullRequestReviewRequest) GetBody() string {
	if p == nil || p.Body == nil {
		return ""
	}
	return *p.Body
}
348095
func ResponseBody(res *http.Response) ([]byte, error) {
	defer res.Body.Close()
	contents, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return []byte{}, err
	}
	return contents, nil
}
436117
func decodeBody(req *http.Request, out interface{}) error {
	dec := json.NewDecoder(req.Body)
	return dec.Decode(&out)
}
415839
func (i *Issue) GetBody() string {
	if i == nil || i.Body == nil {
		return ""
	}
	return *i.Body
}
824055
func (ctx *Context) DecodeXML(obj interface{}) error {
	body, err := ctx.Body()
	if err != nil {
		return err
	}

	return xml.Unmarshal(body, obj)
}
919514
func (r *RepositoryComment) GetBody() string {
	if r == nil || r.Body == nil {
		return ""
	}
	return *r.Body
}
819300
func (r *Request) JsonBody(instance interface{}) error {
	decoder := json.NewDecoder(r.Body)
	defer r.Body.Close()

	return decoder.Decode(instance)
}
262729
func (v *Error) ErrorBody() string {
	var s string
	switch v.Type {
	case ErrorTypeRequired, ErrorTypeForbidden, ErrorTypeTooLong, ErrorTypeInternal:
		s = fmt.Sprintf("%s", v.Type)
	default:
		var bad string
		badBytes, err := json.Marshal(v.BadValue)
		if err != nil {
			bad = err.Error()
		} else {
			bad = string(badBytes)
		}
		s = fmt.Sprintf("%s: %s", v.Type, bad)
	}
	if len(v.Detail) != 0 {
		s += fmt.Sprintf(": %s", v.Detail)
	}
	return s
}
1273508
func (r *httpJSONResponse) ParseArrayBody() ([]driver.Response, error) {
	if r.bodyArray == nil {
		var bodyArray []map[string]*json.RawMessage
		if err := json.Unmarshal(r.rawResponse, &bodyArray); err != nil {
			return nil, driver.WithStack(err)
		}
		r.bodyArray = bodyArray
	}
	resps := make([]driver.Response, len(r.bodyArray))
	for i, x := range r.bodyArray {
		resps[i] = &httpJSONResponseElement{bodyObject: x}
	}
	return resps, nil
}
259237
func ErrorBody(body string, v ...interface{}) string {
	return fmt.Sprintf("%s\n", wordwrap.WrapString(fmt.Sprintf(body, v...), 40))
}
189173
func (c *Client) getBody(url *url.URL, mediaType string) (patch io.ReadCloser, result *Result) {
	result = sendRequest(c, url, func(req *Request) (*Response, error) {
		req.Header.Set("Accept", mediaType)
		return req.Get(nil)
	})

	if result.Response != nil {
		patch = result.Response.Body
	}

	return
}