// readBodyString reads the request body into a string for comparing
975821
func readBodyString(body io.ReadCloser) string {
	buf := new(bytes.Buffer)
	_, err := buf.ReadFrom(body)
	if err != nil {
		lumber.Trace("Failed to read body into string - %s", err.Error())
		return ""
	}

	return buf.String()
}
136305
func (a *Attachment) GetBody() string {
	if a == nil || a.Body == nil {
		return ""
	}
	return *a.Body
}
170042
func ReadResponseBody(response *http.Response) ([]byte, error) {
	defer response.Body.Close()
	return ioutil.ReadAll(response.Body)
}
775404
func readLPString(buf []byte, t Type) (string, int, error) {
	if len(buf) < 2 {
		return "", 0, makeError(t, "insufficient buffer size, expected 2, got %d", len(buf))
	}

	n, total := 0, 0

	n = int(binary.BigEndian.Uint16(buf))
	total += 2
	total += n

	if len(buf) < total {
		return "", total, makeError(t, "insufficient buffer size, expected %d, got %d", total, len(buf))
	}

	return string(buf[2:total]), total, nil
}
1308087
func (a *AuthServerCodec) ReadRequestBody(body interface{}) error {
	if a.lastError != nil {
		return a.lastError
	}
	// TODO: Use reflection and add the identity to the body if necessary
	return a.wrappedcodec.ReadRequestBody(body)
}
885331
func (r *httpJSONResponse) ParseBody(field string, result interface{}) error {
	if r.bodyObject == nil {
		bodyMap := make(map[string]*json.RawMessage)
		if err := json.Unmarshal(r.rawResponse, &bodyMap); err != nil {
			return driver.WithStack(err)
		}
		r.bodyObject = bodyMap
	}
	if result != nil {
		if err := parseBody(r.bodyObject, field, result); err != nil {
			return driver.WithStack(err)
		}
	}
	return nil
}
920953
func (s *XPackWatcherExecuteWatchService) BodyString(body string) *XPackWatcherExecuteWatchService {
	s.bodyString = body
	return s
}
809402
func (b *ByteBuffer) ReadString(delim byte) (string, error) {
	b.Lock()
	defer b.Unlock()
	return b.b.ReadString(delim)
}
131638
func (s *PutTemplateService) BodyString(body string) *PutTemplateService {
	s.bodyString = body
	return s
}
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
}
1088925
func (s *IndicesPutMappingService) BodyString(mapping string) *IndicesPutMappingService {
	s.bodyString = mapping
	return s
}
1289653
func (c *msgpackCodec) ReadBody(v interface{}) error {
	if !c.body {
		return nil
	}

	r := msgp.NewReader(c.rwc)

	// Body is present, but no value to decode into.
	if v == nil {
		return r.Skip()
	}

	switch c.mt {
	case codec.Request, codec.Response, codec.Publication:
		return decodeBody(r, v)
	default:
		return fmt.Errorf("Unrecognized message type: %v", c.mt)
	}
}
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
}
1301562
func (s *IndicesShrinkService) BodyString(body string) *IndicesShrinkService {
	s.bodyString = body
	return s
}
1113378
func (s *ExplainService) BodyString(body string) *ExplainService {
	s.bodyString = body
	return s
}
581967
func readBlockString(s *source.Source, start int) (Token, error) {
	body := s.Body
	position := start + 3
	runePosition := start + 3
	chunkStart := position
	var valueBuffer bytes.Buffer

	for {
		// Stop if we've reached the end of the buffer
		if position >= len(body) {
			break
		}

		code, n := runeAt(body, position)

		// Closing Triple-Quote (""")
		if code == '"' {
			x, _ := runeAt(body, position+1)
			y, _ := runeAt(body, position+2)
			if x == '"' && y == '"' {
				stringContent := body[chunkStart:position]
				valueBuffer.Write(stringContent)
				value := blockStringValue(valueBuffer.String())
				return makeToken(BLOCK_STRING, start, position+3, value), nil
			}
		}

		// SourceCharacter
		if code < 0x0020 &&
			code != 0x0009 &&
			code != 0x000a &&
			code != 0x000d {
			return Token{}, gqlerrors.NewSyntaxError(s, runePosition, fmt.Sprintf(`Invalid character within String: %v.`, printCharCode(code)))
		}

		// Escape Triple-Quote (\""")
		if code == '\\' { // \
			x, _ := runeAt(body, position+1)
			y, _ := runeAt(body, position+2)
			z, _ := runeAt(body, position+3)
			if x == '"' && y == '"' && z == '"' {
				stringContent := append(body[chunkStart:position], []byte(`"""`)...)
				valueBuffer.Write(stringContent)
				position += 4     // account for `"""` characters
				runePosition += 4 // "       "   "     "
				chunkStart = position
				continue
			}
		}

		position += n
		runePosition++
	}

	return Token{}, gqlerrors.NewSyntaxError(s, runePosition, "Unterminated string.")
}
425065
func readBody(resp *http.Response) ([]byte, error) {
	defer resp.Body.Close()
	contentLength := resp.ContentLength
	if contentLength < 0 {
		// Don't know the content length, do it the slowest way
		result, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return nil, driver.WithStack(err)
		}
		return result, nil
	}
	buf := &bytes.Buffer{}
	if int64(int(contentLength)) == contentLength {
		// contentLength is an int64. If we can safely cast to int, use Grow.
		buf.Grow(int(contentLength))
	}
	if _, err := buf.ReadFrom(resp.Body); err != nil {
		return nil, driver.WithStack(err)
	}
	return buf.Bytes(), nil
}