Decode OffsetFetchResponse to OffsetFetchResponsePayloads

        Arguments:
            response: OffsetFetchResponse
10707
def decode_offset_fetch_response(cls, response):
        
        return [
            kafka.structs.OffsetFetchResponsePayload(
                topic, partition, offset, metadata, error
            )
            for topic, partitions in response.topics
            for partition, offset, metadata, error in partitions
        ]
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()
811802
def _parse_response(self, response):
        

        response_dict = {}
        for line in response.splitlines():
            key, value = response.split("=", 1)
            response_dict[key] = value
        return response_dict
135664
def decode(self, value, force=False):
        ""
        if (self.decode_responses or force) and isinstance(value, bytes):
            value = value.decode(self.encoding, self.encoding_errors)
        return value
41966
def _decode_request(self, encoded_request):
        """"""
        obj = self.serializer.loads(encoded_request)
        return request_from_dict(obj, self.spider)
1312028
private synchronized void awaitResponse() throws BOSHException {
        HttpEntity entity = null;
        try {
            HttpResponse httpResp = client.execute(post, context);
            entity = httpResp.getEntity();
            byte[] data = EntityUtils.toByteArray(entity);
            String encoding = entity.getContentEncoding() != null ?
                    entity.getContentEncoding().getValue() :
                    null;
            if (ZLIBCodec.getID().equalsIgnoreCase(encoding)) {
                data = ZLIBCodec.decode(data);
            } else if (GZIPCodec.getID().equalsIgnoreCase(encoding)) {
                data = GZIPCodec.decode(data);
            }
            body = StaticBody.fromString(new String(data, CHARSET));
            statusCode = httpResp.getStatusLine().getStatusCode();
            sent = true;
        } catch (IOException iox) {
            abort();
            toThrow = new BOSHException("Could not obtain response", iox);
            throw(toThrow);
        } catch (RuntimeException ex) {
            abort();
            throw(ex);
        }
    }
1362498
def sync_fetch(request, method, default_headers=None,
               httpclient=None, **kwargs):
    
    updated_request = make_request(request, method, default_headers, **kwargs)
    if not httpclient:
        httpclient = HTTPClient()
    rsp = httpclient.fetch(updated_request)
    return parse_response(rsp)
273329
def decode_iter_request(data: dict) -> Optional[Union[str, int]]:
    
    if "response_metadata" in data:
        return data["response_metadata"].get("next_cursor")
    elif "paging" in data:
        current_page = int(data["paging"].get("page", 1))
        max_page = int(data["paging"].get("pages", 1))

        if current_page < max_page:
            return current_page + 1
    elif "has_more" in data and data["has_more"] and "latest" in data:
        return data["messages"][-1]["ts"]

    return None
304625
def decode_offset_commit_response(cls, data):
        
        ((correlation_id,), cur) = relative_unpack('>i', data, 0)
        ((num_topics,), cur) = relative_unpack('>i', data, cur)

        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), cur) = relative_unpack('>ih', data, cur)
                yield OffsetCommitResponse(topic, partition, error)
839223
def parse_response(self, resp):
        
        p, u = self.getparser()

        if hasattr(resp,'text'):
            # modern requests will do this for us
            text = resp.text # this is unicode(py2)/str(py3)
        else:

            encoding = requests.utils.get_encoding_from_headers(resp.headers)
            if encoding is None:
                encoding='utf-8' # FIXME: what to do here?

            if sys.version_info[0]==2:
                text = unicode(resp.content, encoding, errors='replace')
            else:
                assert sys.version_info[0]==3
                text = str(resp.content, encoding, errors='replace')
        p.feed(text)
        p.close()
        return u.close()
595528
def _get_response(self, **kwargs):
        
        # pylint: disable=E1101
        url = self.read_url + "?output=JSON&token=%s" % self.read_token
        for key in kwargs:
            if key and kwargs[key]:
                val = kwargs[key]
                if isinstance(val, (list, tuple)):
                    val = ",".join(val)
                url += "&%s=%s" % (key, val)
        self._api_url = url
        req = urllib2.urlopen(url)
        data = simplejson.loads(req.read())
        self._api_raw_data = data
        if data and data.get('error', None):
            exceptions.BrightcoveError.raise_exception(
                data['error'])
        if data == None:
            raise exceptions.NoDataFoundError(
                "No data found for %s" % repr(kwargs))
        return data
417075
def _decode_response(self, ip_address):
        
        # Reverse the IP, reassign the octets to integers
        vt, ts, days, rc = [int(o) for o in ip_address.split('.')[::-1]]

        # 127 reflects a valid query response, all others are errors
        if rc != 127:
            raise ValueError('Invalid Response Code: {}'.format(rc))

        # Build a list of visitor types since one IP can be multiple
        visitor_types = []
        if vt & COMMENT_SPAMMER:
            visitor_types.append(COMMENT_SPAMMER)
        if vt & HARVESTER:
            visitor_types.append(HARVESTER)
        if vt & SUSPICIOUS:
            visitor_types.append(SUSPICIOUS)

        # Return the response dictionary
        return {'days_since_last_activity': days if vt else None,
                'name': None if vt else SEARCH_ENGINES[ts],
                'threat_score': ts if vt else None,
                'type': visitor_types if vt else [SEARCH_ENGINE]}
91419
public void receiveResponse(byte[] data,SplitDetails[] msg,Integer txID,ReturnCode returnCode) 
	{
		cancelReTransmissionTimer();
		cancelLongtranTimer();
		JainMgcpResponseEvent event = null;

		try 
		{
			event = decodeResponse(data,msg,txID,returnCode);
		} 
		catch (Exception e) 
		{
			logger.error("Could not decode message: ", e);
		}

		event.setTransactionHandle(remoteTID);
		if (this.isProvisional(event.getReturnCode())) 
			resetLongtranTimer();
		
		stack.provider.processMgcpResponseEvent(event, commandEvent);

		if (!this.isProvisional(event.getReturnCode())) 
			this.release();		
	}
1223986
def decode_fetch_response(cls, response):
        
        return [
            kafka.structs.FetchResponsePayload(
                topic, partition, error, highwater_offset, [
                    offset_and_msg
                    for offset_and_msg in cls.decode_message_set(messages)])
            for topic, partitions in response.topics
                for partition, error, highwater_offset, messages in partitions
        ]
470590
def parse_response(self, response):
        
        status = response.status_code
        if response.ok:
            data = response.json()
            return HttpResponse(ok=response.ok, status=status, errors=None, data=data)
        else:
            try:
                errors = response.json()
            except ValueError:
                errors = response.content
            return HttpResponse(ok=response.ok, status=status, errors=errors, data=None)
1349988
private <T extends Object> T getResponse(HttpResponse httpResponse, Class<T> clazz) throws IOException, HttpRosetteAPIException {
        int status = httpResponse.getStatusLine().getStatusCode();
        String encoding = headerValueOrNull(httpResponse.getFirstHeader(HttpHeaders.CONTENT_ENCODING));

        try (
                InputStream stream = httpResponse.getEntity().getContent();
                InputStream inputStream = "gzip".equalsIgnoreCase(encoding) ? new GZIPInputStream(stream) : stream) {
            String ridHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-DocumentRequest-Id"));
            if (HTTP_OK != status) {
                String ecHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Code"));
                String emHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Message"));
                String responseContentType = headerValueOrNull(httpResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE));
                if ("application/json".equals(responseContentType)) {
                    ErrorResponse errorResponse = mapper.readValue(inputStream, ErrorResponse.class);
                    if (ridHeader != null) {
                        LOG.debug("DocumentRequest ID " + ridHeader);
                    }
                    if (ecHeader != null) {
                        errorResponse.setCode(ecHeader);
                    }
                    if (429 == status) {
                        String concurrencyMessage = "You have exceeded your plan's limit on concurrent calls. "
                                + "This could be caused by multiple processes or threads making Rosette API calls in parallel, "
                                + "or if your httpClient is configured with higher concurrency than your plan allows.";
                        if (emHeader == null) {
                            emHeader = concurrencyMessage;
                        } else {
                            emHeader = concurrencyMessage + System.lineSeparator() + emHeader;
                        }
                    }
                    if (emHeader != null) {
                        errorResponse.setMessage(emHeader);
                    }
                    throw new HttpRosetteAPIException(errorResponse, status);
                } else {
                    String errorContent;
                    if (inputStream != null) {
                        byte[] content = getBytes(inputStream);
                        errorContent = new String(content, "utf-8");
                    } else {
                        errorContent = "(no body)";
                    }
                    // something not from us at all
                    throw new HttpRosetteAPIException("Invalid error response (not json)",
                            ErrorResponse.builder().code("invalidErrorResponse").message(errorContent).build(), status);
                }
            } else {
                return mapper.readValue(inputStream, clazz);
            }
        }
    }
1168130
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    if not client_message.read_bool():
        parameters['response'] = EntryViewCodec.decode(client_message, to_object)
    return parameters