Content of the response, in bytes.
2809
def content(self):
        """"""

        if self._content is False:
            # Read the contents.
            if self._content_consumed:
                raise RuntimeError(
                    'The content for this response was already consumed')

            if self.status_code == 0 or self.raw is None:
                self._content = None
            else:
                self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()

        self._content_consumed = True
        # don't need to release the connection; that's been handled by urllib3
        # since we exhausted the data.
        return self._content
1055773
def _map_response(response, decode=False):
    """"""
    # This causes weird deepcopy errors, so it's commented out for now.
    # item._urllib3_response = response
    item = httplib2.Response(response.getheaders())
    item.status = response.status
    item['status'] = str(item.status)
    item.reason = response.reason
    item.version = response.version

    # httplib2 expects the content-encoding header to be stripped and the
    # content length to be the length of the uncompressed content.
    # This does not occur for 'HEAD' requests.
    if decode and item.get('content-encoding') in ['gzip', 'deflate']:
        item['content-length'] = str(len(response.data))
        item['-content-encoding'] = item.pop('content-encoding')

    return item
227611
def body(self, data):
        """"""
        if data is not None:
            self._body = data
            self.add_header('Content-Length', str(len(self._body)))
188615
def to_bytes(s, encoding="utf-8"):
    """"""
    if isinstance(s, six.binary_type):
        return s
    if six.PY3:
        return bytes(s, encoding)
    return s.encode(encoding)
724148
def content(self):
        """"""

        if self.payload:
            message_bytes = mime_to_bytes(
                self.payload, 0).replace(b'\n', b'\r\n')
            boundary = b'--' + self.payload.get_boundary().encode('utf-8')
            temp = message_bytes.split(boundary)
            temp.pop(0)
            return boundary + boundary.join(temp)
        else:
            return ''
1220845
def format_response(self, response_data):
        """"""

        _addr, length = self.response_info()
        if len(response_data) != length:
            raise HardwareError("Invalid response read length, should be the same as what response_info() returns", expected=length, actual=len(response_data))

        resp, flags, received_length, payload = struct.unpack("<HxBL4x20s", response_data)
        resp = resp & 0xFF
        if flags & (1 << 3):
            raise HardwareError("Could not grab external gate")

        if received_length > 20:
            raise HardwareError("Invalid received payload length > 20 bytes", received_length=received_length)

        payload = payload[:received_length]

        return {
            'status': resp,
            'payload': payload
        }
809681
def parse_content_encoding(self, response_headers, response_data):
        
        if response_headers['content-encoding'] == 'gzip':
            buf = StringIO.StringIO(response_data)
            zipbuf = gzip.GzipFile(fileobj=buf)
            response_data = zipbuf.read()
        elif response_headers['content-encoding'] == 'deflate':
            data = StringIO.StringIO(zlib.decompress(response_data))
            response_data = data.read()
        else:
            raise errors.TestError(
                'Received unknown Content-Encoding',
                {
                    'content-encoding':
                        str(response_headers['content-encoding']),
                    'function': 'http.HttpResponse.parse_content_encoding'
                })
        return response_data
727270
def content_bytes(self):
        """"""
        get_message = \
            self._communication.needle_positions.get_line_configuration_message
        return get_message(self._line_number)
1257744
def _request_process_octet(response):
        
        status = 'Failure'
        # Handle document download
        data = response.content
        if data:
            status = 'Success'

        return data, status
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;
    }
655085
def decode_response(content: bytes) -> set:
    
    content = content[4:].decode(config.ENCODING)
    if '\t' not in content and '\n' not in content:
        return set()

    connected_devices = set()
    device_list = [i for i in content.split('\n') if i]
    for each_device in device_list:
        device_id, device_status = each_device.split('\t')
        if device_status == 'device':
            connected_devices.add(device_id)
    return connected_devices
348801
def to_bytes(val):
    
    if val is NoResponse:
        return val
    val = val.replace('\\r', '\r').replace('\\n', '\n')
    return val.encode()
426720
def _chunk(self, response, size=4096):
        
        method = response.headers.get("content-encoding")
        if method == "gzip":
            d = zlib.decompressobj(16+zlib.MAX_WBITS)
            b = response.read(size)
            while b:
                data = d.decompress(b)
                yield data
                b = response.read(size)
                del data
        else:
            while True:
                chunk = response.read(size)
                if not chunk: break
                yield chunk
532247
private byte[] readBody(Map<String, List<String>> headers, WebSocketInputStream input)
    {
        // Get the value of "Content-Length" header.
        int length = getContentLength(headers);

        if (length <= 0)
        {
            // Response body is not available.
            return null;
        }

        try
        {
            // Allocate a byte array of the content length.
            byte[] body = new byte[length];

            //  into the byte array.
            input.readBytes(body, length);

            // Return the content of the response body.
            return body;
        }
        catch (Throwable t)
        {
            // Response body is not available.
            return null;
        }
    }
1176090
def response(self, url):
        """"""
        
        resp = requests.get(url).content
        return self.parseresponse(resp)
172696
def parse_encrypted_response(self, response):
        
        content_type = response.headers['Content-Type']
        if 'protocol="{0}"'.format(self.protocol_string.decode()) in content_type:
            host = urlsplit(response.request.url).hostname
            msg = self._decrypt_response(response, host)
        else:
            msg = response.text

        return msg
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)