Read response payload and decode.
195456
async def text(self,
                   encoding: Optional[str]=None, errors: str='strict') -> str:
        """"""
        if self._body is None:
            await self.read()

        if encoding is None:
            encoding = self.get_encoding()

        return self._body.decode(encoding, errors=errors)
814967
def parse_response(response):
    
    if isinstance(response, tuple):
        if len(response) > 2:
            return response[0], response[1], response[2]
        elif len(response) > 1:
            return response[0], response[1], {}
    try:
        return response.data, response.status_code, response.headers
    except AttributeError:
        return response, 200, {}
1238540
def decode_fetch_response(cls, data):
        
        ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0)

        for _ in range(num_topics):
            (topic, cur) = read_short_string(data, cur)
            ((num_partitions,), cur) = relative_unpack('>i', data, cur)

            for j in range(num_partitions):
                ((partition, error, highwater_mark_offset), cur) = \
                    relative_unpack('>ihq', data, cur)

                (message_set, cur) = read_int_string(data, cur)

                yield FetchResponse(
                    topic, partition, error,
                    highwater_mark_offset,
                    KafkaProtocol._decode_message_set_iter(message_set))
504376
private RESTResponse readResponse() throws IOException {
        // Read response code from the header line.
        HttpCode resultCode = readStatusLine();
        
        // Read and save headers, keeping track of content-length if we find it.
        Map<String, String> headers = new HashMap<String, String>();
        int contentLength = 0;
        String headerLine = readHeader();
        while (headerLine.length() > 2) {
            // Read header and split into parts based on ":" separator. Both parts are
            // trimmed, and the header is up-cased.
            int colonInx = headerLine.indexOf(':');
            String headerName =     // Use the whole line if there's no colon
                colonInx <= 0 ? headerLine.trim().toUpperCase()
                              : headerLine.substring(0, colonInx).trim().toUpperCase();
            String headerValue =    // Use an empty string if there's no colon
                colonInx <= 0 ? "" : headerLine.substring(colonInx + 1).trim();
            headers.put(headerName, headerValue);
            if (headerName.equals(HttpDefs.CONTENT_LENGTH)) {
                try {
                    contentLength = Integer.parseInt(headerValue);
                } catch (NumberFormatException e) {
                    // Turn into IOException
                    throw new IOException("Invalid content-length value: " + headerLine);
                }
            }
            headerLine = readHeader();
        }

        // Final header line should be CRLF
        if (!headerLine.equals("\r\n")) {
            throw new IOException("Header not properly terminated: " + headerLine);
        }
        
        // If we have a response entity, read that now.
        byte[] body = null;
        if (contentLength > 0) {
            body = readBody(contentLength);
            
            // Decompress output entity if needed.
            String contentEncoding = headers.get(HttpDefs.CONTENT_ENCODING);
            if (contentEncoding != null) {
                Utils.require(contentEncoding.equalsIgnoreCase("gzip"),
                              "Unrecognized output Content-Encoding: " + contentEncoding);
                body = Utils.decompressGZIP(body);
            }
        }
        return new RESTResponse(resultCode, body, headers);
    }
554601
def _load_response(response):
    '''
    
    '''

    try:
        data = salt.utils.json.loads(response.text)
    except ValueError:
        data = response.text

    ret = {'code': response.status_code, 'content': data}

    return ret
1028023
def decode(self):
        """"""
        return serialization.decode(self.body, self.content_type,
                                    self.content_encoding)
1290324
def decode(self, data, delimiter=';'):
        """"""
        try:
            list_data = data.rstrip().split(delimiter)
            self.payload = list_data.pop()
            (self.node_id,
             self.child_id,
             self.type,
             self.ack,
             self.sub_type) = [int(f) for f in list_data]
        except ValueError:
            _LOGGER.warning('Error decoding message from gateway, '
                            'bad data received: %s', data.rstrip())
            raise
327785
def decode(raw):
    """"""
    return raw \
        .replace(bytes([SLIP_ESC, SLIP_ESC_END]), bytes([SLIP_END])) \
        .replace(bytes([SLIP_ESC, SLIP_ESC_ESC]), bytes([SLIP_ESC]))
692794
def decode_fetch_response(cls, data):
        
        ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0)

        for _i in range(num_topics):
            (topic, cur) = read_short_ascii(data, cur)
            ((num_partitions,), cur) = relative_unpack('>i', data, cur)

            for _i in range(num_partitions):
                ((partition, error, highwater_mark_offset), cur) = \
                    relative_unpack('>ihq', data, cur)

                (message_set, cur) = read_int_string(data, cur)

                yield FetchResponse(
                    topic, partition, error,
                    highwater_mark_offset,
                    KafkaCodec._decode_message_set_iter(message_set))
381232
def _decode(self, obj):
        
        if self.decode_responses and isinstance(obj, bytes):
            try:
                return obj.decode(self.encoding)
            except UnicodeDecodeError:
                return obj
        return obj
135260
def decode_offset_response(cls, data):
        
        ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0)

        for _i in range(num_topics):
            (topic, cur) = read_short_ascii(data, cur)
            ((num_partitions,), cur) = relative_unpack('>i', data, cur)

            for _i in range(num_partitions):
                ((partition, error, num_offsets), cur) = \
                    relative_unpack('>ihi', data, cur)

                offsets = []
                for _i in range(num_offsets):
                    ((offset,), cur) = relative_unpack('>q', data, cur)
                    offsets.append(offset)

                yield OffsetResponse(topic, partition, error, tuple(offsets))
10839
def _handle_response(res, delimiter):
    """"""
    if res.status_code == 200:
        # Python 2 -- csv.reader will need bytes
        if sys.version_info[0] < 3:
            csv_io = BytesIO(res.content)
        # Python 3 -- csv.reader needs str
        else:
            csv_io = StringIO(res.text)
        data_iter = read_unicode_csv_fileobj(csv_io, delimiter=delimiter,
                                             skiprows=1)
    else:
        raise Exception('Could not download Signor data.')
    return data_iter
973780
def read_body(response, max_bytes=None):
    """"""
    finished = Deferred()
    response.deliverBody(TruncatingReadBodyProtocol(
        response.code, response.phrase, finished, max_bytes))
    return finished
923533
def get_fetch_response(self, raw):
        """"""
        p = Payload(raw)
        p._body = p.body
        return p
1287994
def parseresponse(self, resp):
        """"""
        # Support Python 3's bytes type from socket repsonses
        if sys.version_info.major > 2:
            resp = resp.decode('utf-8')
	
        if self.RESPONSE_TOKEN not in resp:
            raise BustimeError("The Bustime API returned an invalid response: {}".format(resp))
        elif self.ERROR_TOKEN in resp:
            return self.errorhandle(resp)
        else:
            if self.format == 'json':
                return xmltodict.parse(resp)[self.RESPONSE_TOKEN]
            elif self.format == 'xml':
                return resp
670299
def read_response(self):
        
        response = self._read_response()
        frame, data = nsq.unpack_response(response)
        self.last_response = time.time()

        if frame not in self._frame_handlers:
            raise errors.NSQFrameError('unknown frame {}'.format(frame))

        frame_handler = self._frame_handlers[frame]
        processed_data = frame_handler(data)

        return frame, processed_data
75697
def read_response(self):
        ""
        try:
            response = self._parser.read_response()
        except socket.timeout:
            self.disconnect()
            raise TimeoutError("Timeout reading from %s:%s" %
                               (self.host, self.port))
        except socket.error:
            self.disconnect()
            e = sys.exc_info()[1]
            raise ConnectionError("Error while reading from %s:%s : %s" %
                                  (self.host, self.port, e.args))
        except:  # noqa: E722
            self.disconnect()
            raise
        if isinstance(response, ResponseError):
            raise response
        return response