Content of the response, in bytes or unicode
        (if available).
431706
def content(self):
        

        if self._content is not None:
            return self._content

        if self._content_consumed:
            raise RuntimeError('The content for this response was '
                               'already consumed')

        # Read the contents.
        try:
            self._content = self.raw.read()
        except AttributeError:
            return None


        # Decode GZip'd content.
        if 'gzip' in self.headers.get('content-encoding', ''):
            try:
                self._content = decode_gzip(self._content)
            except zlib.error:
                pass

        # Decode unicode content.
        if self.config.get('decode_unicode'):
            self._content = get_unicode_from_response(self)

        self._content_consumed = True
        return self._content
948096
def make_response(response):
    
    if isinstance(response, unicode) or \
            isinstance(response, str):
        response = (response, 'text/html')

    return response
470471
def _write_response(self, response):
        
        status = '{} {} {}\r\n'.format(response['version'],
                                       response['code'],
                                       responses[response['code']])
        self.logger.debug("Responding status: '%s'", status.strip())
        self._write_transport(status)

        if 'body' in response and 'Content-Length' not in response['headers']:
            response['headers']['Content-Length'] = len(response['body'])

        response['headers']['Date'] = datetime.utcnow().strftime(
            "%a, %d %b %Y %H:%M:%S +0000")

        for (header, content) in response['headers'].items():
            self.logger.debug("Sending header: '%s: %s'", header, content)
            self._write_transport('{}: {}\r\n'.format(header, content))

        self._write_transport('\r\n')
        if 'body' in response:
            self._write_transport(response['body'])
1054938
public static String getContentAsString(HttpResponse response) {

		try {
			if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

				HttpEntity entity = response.getEntity();
				Header contentEncoding = entity.getContentEncoding();
				String encoding = contentEncoding != null ? contentEncoding.getValue() : UTF_8;
				return ResourceUtils.getString(entity.getContent(), encoding);
			}
		}
		catch (IOException e) {
			log.error("Failed to read response: ", e.getMessage());
		}

		return null;
	}
727270
def content_bytes(self):
        """"""
        get_message = \
            self._communication.needle_positions.get_line_configuration_message
        return get_message(self._line_number)
97737
def html_with_encoding(self, url, timeout=None, encoding="utf-8"):
        
        response = self.get_response(url, timeout=timeout)
        if response:
            return self.decoder.decode(response.content, encoding)[0]
        else:
            return None
1257744
def _request_process_octet(response):
        
        status = 'Failure'
        # Handle document download
        data = response.content
        if data:
            status = 'Success'

        return data, status
1225998
def content(self):
        
        content = self._get_content()

        if bool(content and '\0' in content):
            return content
        return safe_unicode(content)
735677
private static String getResponseStringData(InputStream is, String charset) throws IOException {
    ByteArrayOutputStream respDataStream = new ByteArrayOutputStream();
    String result;
    try {
      byte[] b = new byte[8192];
      int len;
      while (true) {
        len = is.read(b);
        if (len <= 0) {
          is.close();
          break;
        }
        respDataStream.write(b, 0, len);
      }
      result = respDataStream.toString(charset);
    } finally {
      respDataStream.close();
    }
    return result;
  }
918745
def reply_bytes(self, request):
        """"""
        flags = struct.pack("<i", self._flags)
        cursor_id = struct.pack("<q", self._cursor_id)
        starting_from = struct.pack("<i", self._starting_from)
        number_returned = struct.pack("<i", len(self._docs))
        reply_id = random.randint(0, 1000000)
        response_to = request.request_id

        data = b''.join([flags, cursor_id, starting_from, number_returned])
        data += b''.join([bson.BSON.encode(doc) for doc in self._docs])

        message = struct.pack("<i", 16 + len(data))
        message += struct.pack("<i", reply_id)
        message += struct.pack("<i", response_to)
        message += struct.pack("<i", OP_REPLY)
        return message + data
882875
function (response) {
        var contentType = response.headers.get(HEADERS.CONTENT_TYPE),
            contentDisposition = response.headers.get(HEADERS.CONTENT_DISPOSITION),
            mimeInfo = getMimeInfo(contentType, response.stream || response.body),
            fileName = getFileNameFromDispositionHeader(contentDisposition),
            fileExtension = mimeInfo.extension,

            /**
             * @typedef Response~ResponseContentInfo
             *
             * @property {String} mimeType sanitized mime type
             * @property {String} mimeFormat format for the identified mime type
             * @property {String} charset the normalized character set
             * @property {String} fileExtension extension identified from the mime type
             * @property {String} fileName file name extracted from disposition header
             */
            contentInfo = {};


        // if file name is not present in the content disposition headers, use a default file name
        if (!fileName) {
            fileName = DEFAULT_RESPONSE_FILENAME;
            // add extension to default if present
            fileExtension && (fileName += (DOT + fileExtension));
        }

        // create a compacted list of content info from mime info and file name
        mimeInfo.mimeType && (contentInfo.mimeType = mimeInfo.mimeType);
        mimeInfo.mimeFormat && (contentInfo.mimeFormat = mimeInfo.mimeFormat);
        mimeInfo.charset && (contentInfo.charset = mimeInfo.charset);
        fileExtension && (contentInfo.fileExtension = fileExtension);
        fileName && (contentInfo.fileName = fileName);

        return contentInfo;
    }
161611
def _read_response(self):
    
    result = self.buf.read_line().decode("utf-8")
    if not result:
      raise NoResponseError("No response received from server.")

    msg = self._read_message()
    if result != "ok":
      raise InvalidResponseError(msg)

    return msg
1085508
public static String getResponseContent(HttpResponse response) throws IOException {
        final HttpEntity entity = response.getEntity();
        if (entity != null) {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                entity.writeTo(out);//call this in any case!!!
                return isScOk(response) ? new String(out.toByteArray(), Charset.forName("UTF-8")) : null;
            } finally {
                //ensure entity is closed.
                EntityUtils.consume(entity);
            }
        } else {
            return null;
        }
    }
92604
public static HttpServletResponse getEncodingResponse(
            HttpServletResponse response, String charset) {
        response.setCharacterEncoding(charset);
        response.setContentType("text/html;charset=" + charset);
        return response;
    }
1149082
def _parse_content(response):
    """"""
    if response.status_code != 200:
        raise ApiError(f'unknown error: {response.content.decode()}')
    result = json.loads(response.content)
    if not result['ok']:
        raise ApiError(f'{result["error"]}: {result.get("detail")}')
    return result
975414
async def text(self, *, encoding: Optional[str]=None) -> str:
        """"""
        data = await self.read(decode=True)
        # see https://www.w3.org/TR/html5/forms.html#multipart/form-data-encoding-algorithm # NOQA
        # and https://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#dom-xmlhttprequest-send # NOQA
        encoding = encoding or self.get_charset(default='utf-8')
        return data.decode(encoding)
150432
def contents(self):
        """"""
        if not self._source:
            return ' ' * 100  # HACK - make sure that area is big
        contents = self.source.describe()
        return pretty_describe(contents)