Returns the body as a string.

Note that because the underlying data may be based on a stream, this
method could only work correctly the first time.
541727
public function getBodyAsString(): string
    {
        $body = $this->getBody();
        if (is_string($body)) {
            return $body;
        }
        if (null === $body) {
            return '';
        }
        if (is_callable($body)) {
            ob_start();
            $body();

            return ob_get_clean();
        }
        /**
         * @var string|int|null
         */
        $contentLength = $this->getHeader('Content-Length');
        if (is_int($contentLength) || ctype_digit($contentLength)) {
            return stream_get_contents($body, (int) $contentLength);
        }

        return stream_get_contents($body);
    }
1236030
public String asString() {
        String s = fromStringOrReader();
        if (s != null) return s;
        ByteBuffer bb = getByteBuffer();
        if (bb != null) return stringFrom(bb);
        InputStream is = fromStreamOrUrl();
        if (is != null) {
            Reader r = readerFrom(is);
            return stringFrom(r);
        }
        throw resourceUnaccessible();
    }
1361737
public function getBody()
    {
        if ($this->bodyContents) {
            return $this->bodyContents;
        }

        if (!$this->headerLen) {
            $this->determineHeaderLength();
        }

        fseek($this->fp, $this->headerStart + $this->headerLen, SEEK_SET);

        $this->bodyContents = '';
        while (!feof($this->fp)) {
            $this->bodyContents .= fread($this->fp, 8192);
        }
        fclose($this->fp);

        return $this->bodyContents;
    }
690786
def get_request_body(self):
        
        if self._request_body is None:
            content_type_str = self.request.headers.get(
                'Content-Type', 'application/octet-stream')
            LOGGER.debug('decoding request body of type %s', content_type_str)
            content_type = headers.parse_content_type(content_type_str)
            try:
                selected, requested = algorithms.select_content_type(
                    [content_type], _content_types.values())
            except errors.NoMatch:
                raise web.HTTPError(
                    415, 'cannot decoded content type %s', content_type_str,
                    reason='Unexpected content type')
            handler = _content_handlers[str(selected)]
            try:
                self._request_body = handler.unpack_bytes(
                    self.request.body,
                    encoding=content_type.parameters.get('charset'),
                )
            except ValueError as error:
                raise web.HTTPError(
                    400, 'failed to decode content body - %r', error,
                    reason='Content body decode failure')
        return self._request_body
614919
def decode_body(headers: MutableMapping, body: bytes) -> dict:
    

    type_, encoding = parse_content_type(headers)
    decoded_body = body.decode(encoding)

    # There is one api that just returns `ok` instead of json. In order to have a consistent API we decided to modify the returned payload into a dict.
    if type_ == "application/json":
        payload = json.loads(decoded_body)
    else:
        if decoded_body == "ok":
            payload = {"ok": True}
        else:
            payload = {"ok": False, "data": decoded_body}

    return payload
247279
def get_body(self):
        '''
        '''
        if self._body is None:
            resp = self._dispatcher._dispatch(self.request)
            self._body = self._create_body(resp)
        return self._body
48224
def body(self):
        """"""
        body = None
        if self.body_input:
            body = self.body_input.read(int(self.get_header('content-length', -1)))

        return body
1152288
def normalize_body(self, b):
        
        if b is None: return ''

        if self.is_json():
            # TODO ???
            # I don't like this, if we have a content type but it isn't one
            # of the supported ones we were returning the exception, which threw
            # Jarid off, but now it just returns a string, which is not best either
            # my thought is we could have a body_type_subtype method that would 
            # make it possible to easily handle custom types
            # eg, "application/json" would become: self.body_application_json(b, is_error)
            b = json.dumps(b, cls=ResponseBody)

        else:
            # just return a string representation of body if no content type
            b = String(b, self.encoding)

        return b
690853
private static String getString(InputStream in) {
        try {
            StringBuffer out = new StringBuffer();
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(in));
            String line = reader.readLine();
            while (line != null) {
                out.append(line + "\n");
                line = reader.readLine();
            }
            return out.toString();
        } catch (Exception e) {
            return "[Error reading response body: " + e.getClass().getName()
                    + ": " + e.getMessage() + "]";
        }
    }
438482
@Override
    public byte[] getBody() throws AuthFailureError {
        if (mOutput == null) {
            openOutput();
        }
        try {
            if (mMultipart) {

                mOutput.write(CRLF + "--" + BOUNDARY + "--" + CRLF);
            }
            return mOutput.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
            return mOutput.toByteArray();
        } finally {
            try {
                mOutput.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            mOutput = null;
        }

    }
1321677
def _get_body_string(self):
        
        clen = self.content_length
        if clen > self.MEMFILE_MAX:
            raise HTTPError(413, 'Request entity too large')
        if clen < 0: clen = self.MEMFILE_MAX + 1
        data = self.body.read(clen)
        if len(data) > self.MEMFILE_MAX:  # Fail fast
            raise HTTPError(413, 'Request entity too large')
        return data
1182690
def body_lines(self):
        
        if not self.message.is_multipart():
            body = self.message.get_payload(None, decode=True)
        else:
            _, _, body = self.message.as_string().partition("\n\n")
        if isinstance(body, bytes):
            for enc in ['ascii', 'utf-8']:
                try:
                    body = body.decode(enc)
                    break
                except UnicodeDecodeError:
                    continue
            else:
                body = self.message.get_payload(None, decode=False)
        return body.splitlines(True)
512005
public byte[] getResponseBodyAsByteArray() {
        final ByteBuf bodyByteBuf = httpInputMessage.getBody();
        final byte[] bytes = new byte[bodyByteBuf.readableBytes()];
        bodyByteBuf.readBytes(bytes);
        return bytes;
    }
356364
def get_body(self):
        """"""

        if self.is_multipart():
            # get the plain text version only
            text_parts = [part
                          for part in typed_subpart_iterator(self,
                                                             'text',
                                                             'plain')]
            body = []
            for part in text_parts:
                charset = get_charset(part, get_charset(self))
                body.append(unicode(part.get_payload(decode=True),
                                    charset,
                                    "replace"))

            return u"\n".join(body).strip()

        else:   # if it is not multipart, the payload will be a string
                # representing the message body
            body = unicode(self.get_payload(decode=True),
                           get_charset(self),
                           "replace")
            return body.strip()
906973
function () {
        var mime = this.mime();

        // if there is no mime detected, there is no accurate way to render this thing
        if (!this.mime) {
            return E;
        }

        // we create the body string first from stream and then fallback to body
        return 'data:' + mime._sanitisedContentType + ';base64, ' + ((!_.isNil(this.stream) &&
            util.bufferOrArrayBufferToBase64(this.stream)) || (!_.isNil(this.body) && util.btoa(this.body)) || E);
    }
570872
public function getBody()
    {
        if ($this->stream === null) {
            ob_start();
            $this->htmlElement->toHtml();
            $content = ob_get_clean();
            $this->stream = new Stream('php://memory', 'wb+');
            $this->stream->write($content);
        }

        return $this->stream;
    }
926527
public String getRawDataAsString() throws IOException
    {
        byte[] buffer = getRawData();
        if ( buffer == null ) {
            return null;
        }
        
        String encoding = request.getCharacterEncoding();
        if ( encoding == null ) {
            encoding = "utf-8";
        }
        
        return new String(buffer, encoding);
    }