Decodes the response stream.
nb: many return types from ezjscore extension: text/javascript for json, text/xml for xml
355225
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200"  )
    {
        $this->Cookies = $cookies;
        $this->StatusCode = $statuscode;

        $ct = explode( ';', $headers['content-type'], 2 );
        switch( $ct[0] )
        {
            case 'application/json':
            case 'text/javascript':
                $results = json_decode( $stream, true );
                if ( !is_array( $results ) ||
                    !array_key_exists( 'content', $results ) ||
                    !array_key_exists( 'error_text', $results )
                    )
                {
                    // invalid ezjscore response
                    $this->IsFault = true;
                    $this->FaultCode = self::INVALIDRESPONSEERROR;
                    $this->FaultString = self::INVALIDRESPONSESTRING;
                }
                else
                {

                    if ( $results['error_text'] == '' )
                    {
                        $this->IsFault = false;
                        $this->FaultString = false;
                        $this->FaultCode = false;
                        $this->Value = $results['content'];
                    }
                    else
                    {
                        $this->IsFault = true;
                        $this->FaultCode = self::GENERICRESPONSEERROR;
                        /// @todo we should somehow typecast to string here???
                        $this->FaultString = $results['error_text'];
                    }
                }
                break;
            case 'text/xml':
            case 'application/xml':
            default:
                $this->IsFault = true;
                $this->FaultCode = self::INVALIDRESPONSEERROR;
                $this->FaultString = "Unsupported feature: decoding response in '{$ct[0]}' format";
        }
    }
142498
def decode(response):
        

        # Second stage. Errors are backend errors (bad login, bad url, ...)
        try:
            response.raise_for_status()
        except requests.HTTPError as exp:
            response = {"_status": "ERR",
                        "_error": {"message": exp, "code": response.status_code},
                        "_issues": {"message": exp, "code": response.status_code}}
            return response
        else:
            return response.json()
767963
def response_json(self, status, response, content_type='application/json', encoding='utf-8', headers=None, jsonp=None):
        

        encoder = JSONEncoder(
            check_circular=self.app.validate_output,
            allow_nan=False,
            sort_keys=True,
            indent=2 if self.app.pretty_output else None,
            separators=(',', ': ') if self.app.pretty_output else (',', ':')
        )
        content = encoder.encode(response)
        if jsonp:
            content_list = [jsonp.encode(encoding), b'(', content.encode(encoding), b');']
        else:
            content_list = [content.encode(encoding)]
        return self.response(status, content_type, content_list, headers=headers)
782031
def _convert_json_response_to_entities(response, property_resolver, require_encryption,
                                       key_encryption_key, key_resolver):
    ''' 
    '''
    if response is None or response.body is None:
        return None

    entities = _list()

    entities.next_marker = _get_continuation_from_response_headers(response)

    root = loads(response.body.decode('utf-8'))

    if 'value' in root:
        for entity in root['value']:
            entity = _decrypt_and_deserialize_entity(entity, property_resolver, require_encryption, 
                                           key_encryption_key, key_resolver)
            entities.append(entity)

    else:
        entities.append(_convert_json_to_entity(entity, 
                                             property_resolver))

    return entities
794698
function decode(string) {

        var stack = [], i = -1, decoded,
            type, top, value,
            getKey = false, key, isObj;

        bitsLeft = 8;
        streamIndex = 0;
        bitStream = string;
        bitValue = bitStream.charCodeAt(streamIndex);

        while(true) {

            // Grab type
            type = read(3);

            switch(type) {

            // Bool
            case 0:
                value = read(1) ? true : false;
                break;

            // EOS / Stream Overrun / Null
            case 7:
                switch(read(1)) {
                    case 1:
                        return decoded;

                    case 7:
                        return undefined;

                    default:
                        value = null;
                }
                break;

            // Integer / Float
            case 1:
            case 2:
                switch(read(3)) {
                    case 0:
                        value = read(1);
                        break;

                    case 1:
                        value = read(4);
                        break;

                    case 2:
                        value = read(8);
                        break;

                    case 3:
                        value = (read(4) << 8)
                                + read(8);

                        break;

                    case 4:
                        value = (read(8) << 8)
                                + read(8);

                        break;

                    case 5:
                        value = (read(4) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;

                    case 6:
                        value = (read(8) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;

                    case 7:
                        value = (read(8) << 24)
                                + (read(8) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;
                }

                if (read(1)) {
                    value = -value;
                }

                if (type === 2) {
                    value /= reversePowTable[read(4)];
                }

                break;

            // String
            case 3:

                var size = read(5);
                switch(size) {
                    case 31:
                        size = (read(8) << 24)
                               + (read(8) << 16)
                               + (read(8) << 8)
                               + read(8);

                        break;

                    case 30:
                        size = (read(8) << 8)
                               + read(8);

                        break;

                    case 29:
                        size = read(8);
                        break;

                }

                // Read a raw string from the stream
                if (bitsLeft !== 8) {
                    streamIndex++;
                    bitValue = 0;
                    bitsLeft = 8;
                }

                value = bitStream.substr(streamIndex, size);
                streamIndex += size;
                bitValue = bitStream.charCodeAt(streamIndex);

                if (getKey) {
                    key = value;
                    getKey = false;
                    continue;
                }

                break;

            // Open Array / Objects
            case 4:
            case 5:
                getKey = type === 5;
                value = getKey ? {} : [];

                if (decoded === undefined) {
                    decoded = value;

                } else {

                    if (isObj) {
                        top[key] = value;

                    } else {
                        top.push(value);
                    }
                }

                top = stack[++i] = value;
                isObj = !(top instanceof Array);
                continue;

            // Close Array / Object
            case 6:
                top = stack[--i];
                getKey = isObj = !(top instanceof Array);
                continue;
            }

            // Assign value to top of stack or return value
            if (isObj) {
                top[key] = value;
                getKey = true;

            } else if (top !== undefined) {
                top.push(value);

            } else {
                return value;
            }

        }

    }
894204
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    if not client_message.read_bool():
        parameters['response'] = to_object(client_message.read_data())
    return parameters
621275
def decode(self, stream, encoding='utf-8'):
        
        data = stream.read().decode(encoding).strip("\n")
        if data != "":
            logger.debug(('{0}: decoded "{1}" with encoding '
                          '{2}'.format(self.target_address, data, encoding)))
        return data
1270626
def decode(cls, value):
        
        try:
            return None if value is None else \
                list(json.loads(value.decode(cls._encoding)))
        except (TypeError, AttributeError):
            return list(value)
196629
def decode_response(client_message, to_object=None):
    
    parameters = dict(read_count=None, items=None)
    parameters['read_count'] = client_message.read_int()
    items_size = client_message.read_int()
    items = []
    for _ in range(0, items_size):
        items_item = client_message.read_data()
        items.append(items_item)
    parameters['items'] = ImmutableLazyDataList(items, to_object)
    return parameters
681445
def _api_convert_output(return_value):
    
    content_type = web.ctx.environ.get('CONTENT_TYPE', 'text/json')

    if "text/json" in content_type:
        web.header('Content-Type', 'text/json; charset=utf-8')
        return json.dumps(return_value)
    if "text/html" in content_type:
        web.header('Content-Type', 'text/html; charset=utf-8')
        dump = yaml.dump(return_value)
        return "<pre>" + web.websafe(dump) + "</pre>"
    if "text/yaml" in content_type or \
                    "text/x-yaml" in content_type or \
                    "application/yaml" in content_type or \
                    "application/x-yaml" in content_type:
        web.header('Content-Type', 'text/yaml; charset=utf-8')
        dump = yaml.dump(return_value)
        return dump
    web.header('Content-Type', 'text/json; charset=utf-8')
    return json.dumps(return_value)
1216215
def parse_response(response):
    
    if response.headers.get('Content-Type', JSON_TYPE).startswith(JSON_TYPE):
        return ResponseObject(json.loads(response.body))
    else:
        return response.body
585685
def _deserialize(self):
        
        if not self._responses or not self._responses[-1].body:
            return None
        if 'Content-Type' not in self._responses[-1].headers:
            return self._responses[-1].body
        try:
            content_type = algorithms.select_content_type(
                [headers.parse_content_type(
                    self._responses[-1].headers['Content-Type'])],
                AVAILABLE_CONTENT_TYPES)
        except errors.NoMatch:
            return self._responses[-1].body

        if content_type[0] == CONTENT_TYPE_JSON:
            return self._decode(
                self._json.loads(self._decode(self._responses[-1].body)))
        elif content_type[0] == CONTENT_TYPE_MSGPACK:  # pragma: nocover
            return self._decode(
                self._msgpack.unpackb(self._responses[-1].body))
714595
function () {
    try {
      return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
    } catch (error) {
      console.log(error);
    }
    return false;
  }
609413
def decode_response_body(response)
      check_response_status_code(response)
      body = MultiJson.load(response.body, :symbolize_keys => true)
      check_body_error(response, body)
      body
    end
75494
def decode_response(status: int, headers: MutableMapping, body: bytes) -> dict:
    
    data = decode_body(headers, body)
    raise_for_status(status, headers, data)
    raise_for_api_error(headers, data)

    return data
76263
def decode_consumermetadata_response(cls, data):
        
        (correlation_id, error_code, node_id), cur = \
            relative_unpack('>ihi', data, 0)
        host, cur = read_short_ascii(data, cur)
        (port,), cur = relative_unpack('>i', data, cur)

        return ConsumerMetadataResponse(
            error_code, node_id, nativeString(host), port)
356887
def decode(self, fp: TextIO) -> BioCCollection:
        
        # utf8_parser = etree.XMLParser(encoding='utf-8')
        tree = etree.parse(fp)
        collection = self.__parse_collection(tree.getroot())
        collection.encoding = tree.docinfo.encoding
        collection.standalone = tree.docinfo.standalone
        collection.version = tree.docinfo.xml_version
        return collection