marshals response data into page data
431541
def _set_data(self, action):
        
        if 'query' in action:
            self._set_query_data(action)
        elif action == 'imageinfo':
            self._set_imageinfo_data()
        elif action == 'parse':
            self._set_parse_data()
        elif action == 'random':
            self._set_random_data()
        elif action == 'labels':
            self._set_labels()
        elif action == 'wikidata':
            self._set_wikidata()
            self.get_labels()
        elif action == 'restbase':
            self._set_restbase_data()

        self._update_imageinfo()
        self._update_params()
528985
def get_paginated_response(self, data):
        
        return Response({
            'next': self.get_next_link(),
            'previous': self.get_previous_link(),
            'count': self.page.paginator.count,
            'num_pages': self.page.paginator.num_pages,
            'current_page': self.page.number,
            'start': (self.page.number - 1) * self.get_page_size(self.request),
            'results': data
        })
262863
def _data_from_response(self, resp_body, key=None):
        
        if key:
            data = resp_body.get(key)
        else:
            data = resp_body.get(self.plural_response_key, resp_body)
        # NOTE(ja): some services, such as keystone returns values as list as
        # {"values": [ ... ]} unlike other services which just return the
        # list.
        if isinstance(data, dict):
            try:
                data = data["values"]
            except KeyError:
                pass
        return data
1372445
def load_page(self, payload):
        
        if 'meta' in payload and 'key' in payload['meta']:
            return payload[payload['meta']['key']]
        else:
            keys = set(payload.keys())
            key = keys - self.META_KEYS
            if len(key) == 1:
                return payload[key.pop()]

        raise TwilioException('Page Records can not be deserialized')
1371553
def _parse_scram_response(response):
    """"""
    return dict(item.split(b"=", 1) for item in response.split(b","))
69367
function getNextPageUrl(response) {
  const link = response.headers.get('link');
  if (!link) {
    return null;
  }

  const nextLink = link.split(',').filter(s => s.indexOf('rel="next"') > -1)[0];
  if (!nextLink) {
    return null;
  }

  return nextLink.split(';')[0].slice(1, -1);
}
370737
function reanderPage(Handler, data) {
    React.render(React.createElement(Handler, { data: data }), document);
}
359242
def _load_response(self, action):
        
        _query = self.cache[action]['query'].replace('&format=json', '')
        response = self.cache[action]['response']

        if not response:
            raise ValueError("Empty response: %s" % self.params)

        try:
            data = utils.json_loads(response)
        except ValueError:
            raise ValueError(_query)

        if data.get('warnings'):
            if 'WARNINGS' in self.data:
                self.data['WARNINGS'].update(data['warnings'])
            else:
                self.data['WARNINGS'] = data['warnings']

        if data.get('error'):
            utils.stderr("API error: %s" % data.get('error'))
            raise LookupError(_query)

        if 'query' in action and data.get('query'):
            if data['query'].get('pages'):
                if data['query']['pages'][0].get('missing'):
                    raise LookupError(_query)

        if action == 'parse' and not data.get('parse'):
            raise LookupError(_query)

        if action == 'wikidata':
            handle_wikidata_errors(data, _query)

        return data
415469
def from_response_data(cls, response_data):
        

        response_json = response_data.json()

        return cls(
            response_data.url,
            response_json["number_of_page_results"],
            response_json["number_of_total_results"],
            response_json["results"],
        )
412575
def write_pagination_headers(data, offset, limit, response, uripath,
                             resource_name):
    
    items = data.get('results') or data.get('data') or {}
    count = len(items)
    try:
        total = int(data['collection-count'])
    except (ValueError, TypeError, KeyError):
        total = None
    if total is None and offset == 0 and (limit is None or limit > len(items)):
        total = count

    # Set 'content-range' header
    response.set_header(
        'Content-Range',
        "%s %d-%d/%s" % (resource_name, offset, offset + max(count - 1, 0),
                         total if total is not None else '*')
    )

    partial = False
    if offset:
        partial = True  # Any offset automatically means we've skipped data
    elif total is None and count == limit:
        # Unknown total, but first page is full (so there may be more)
        partial = True  # maybe more records in next page
    elif total > count:
        # Known total and not all records returned
        partial = True

    if partial:
        uripath = uripath.strip('/')
        response.status = 206  # Partial

        # Add Next page link to http header
        if total is None or (offset + limit) < total - 1:
            nextfmt = (
                '</%s?limit=%d&offset=%d>; rel="next"; title="Next page"')
            response.add_header(
                "Link", nextfmt % (uripath, limit, offset + limit)
            )

        # Add Previous page link to http header
        if offset > 0 and (offset - limit) >= 0:
            prevfmt = ('</%s?limit=%d&offset=%d>; rel="previous"; '
                       'title="Previous page"')
            response.add_header(
                "Link", prevfmt % (uripath, limit, offset - limit)
            )

        # Add first page link to http header
        if offset > 0:
            firstfmt = '</%s?limit=%d>; rel="first"; title="First page"'
            response.add_header(
                "Link", firstfmt % (uripath, limit))

        # Add last page link to http header
        if (total is not None and  # can't calculate last page if unknown total
                limit and  # if no limit, then any page is the last page!
                limit < total):
            lastfmt = '</%s?offset=%d>; rel="last"; title="Last page"'
            if limit and total % limit:
                last_offset = total - (total % limit)
            else:
                last_offset = total - limit
            response.add_header(
                "Link", lastfmt % (uripath, last_offset))
1235092
function () {
        if (req.status !== 200) {
          console.warn(req.responseText);
          return;
        }
        // Show the raw response text on page
        xmlOutput.textContent = req.responseText;
        // convert XML to javascript objects
        var json = sdmxmllib.mapSDMXMLResponse(req.responseText);
        // Convert to json and show on page
        jsonOutput.textContent = JSON.stringify(json, null, 2);
    }
1365324
def do_response(self, response_id):
        '''
        '''
        if response_id != Gtk.ResponseType.OK:
            return
        filelist = []
        for row in self.rows:
            if row[1].get_text() == row[2].get_text():
                continue
            filelist.append({'path': row[0], 'newname': row[2].get_text()})
        if len(filelist) == 0:
            return
        pcs.rename(self.app.cookie, self.app.tokens, filelist)
        gutil.async_call(pcs.rename, self.app.cookie, self.app.tokens,
                         filelist, callback=self.app.reload_current_page)
1003175
def _BuildResponse(self,
                     status,
                     rendered_data,
                     method_name=None,
                     headers=None,
                     content_length=None,
                     token=None,
                     no_audit_log=False):
    """"""

    # To avoid IE content sniffing problems, escape the tags. Otherwise somebody
    # may send a link with malicious payload that will be opened in IE (which
    # does content sniffing and doesn't respect Content-Disposition header) and
    # IE will treat the document as html and executre arbitrary JS that was
    # passed with the payload.
    str_data = json.Dump(
        rendered_data, encoder=JSONEncoderWithRDFPrimitivesSupport)
    # XSSI protection and tags escaping
    rendered_data = ")]}'\n" + str_data.replace("<", r"\u003c").replace(
        ">", r"\u003e")

    response = werkzeug_wrappers.Response(
        rendered_data,
        status=status,
        content_type="application/json; charset=utf-8")
    response.headers[
        "Content-Disposition"] = "attachment; filename=response.json"
    response.headers["X-Content-Type-Options"] = "nosniff"

    if token and token.reason:
      response.headers["X-GRR-Reason"] = utils.SmartStr(token.reason)
    if method_name:
      response.headers["X-API-Method"] = method_name
    if no_audit_log:
      response.headers["X-No-Log"] = "True"

    for key, value in iteritems(headers or {}):
      response.headers[key] = value

    if content_length is not None:
      response.content_length = content_length

    return response
1033338
function() {
                if(partialOutputMode === 'disabled') {
                    return;
                }
                if(outputBinary) {
                    responseByteArray(xhr, partialBuffer);
                } else {
                    partialBuffer = xhr.responseText;
                }
                partial = partialOutputMode === 'joined' ? partialBuffer : partialBuffer.slice(partialPosition);
                partialPosition = partialBuffer.length;
            }
345340
def _wrap_paginated_response(cls, request, response, controls, data,
                                 head=None):
        
        paging_response = response['paging']
        if head is None:
            head = response['head_id']
        link = cls._build_url(
            request,
            head=head,
            start=paging_response['start'],
            limit=paging_response['limit'])

        paging = {}
        limit = controls.get('limit')
        start = controls.get("start")
        paging["limit"] = limit
        paging["start"] = start
        # If there are no resources, there should be nothing else in paging
        if paging_response.get("next") == "":
            return cls._wrap_response(
                request,
                data=data,
                metadata={
                    'head': head,
                    'link': link,
                    'paging': paging
                })

        next_id = paging_response['next']
        paging['next_position'] = next_id

        # Builds paging urls specific to this response
        def build_pg_url(start=None):
            return cls._build_url(request, head=head, limit=limit, start=start)

        paging['next'] = build_pg_url(paging_response['next'])

        return cls._wrap_response(
            request,
            data=data,
            metadata={
                'head': head,
                'link': link,
                'paging': paging
            })
137510
def _handle_response(self, response, data):
        
        # Content-Type headers can include additional parameters(RFC 1521), so
        # we split on ; to match against only the type/subtype
        if data and response.get('content-type', '').split(';')[0] in (
            'application/json', 
            'application/x-javascript',
            'text/javascript',
            'text/x-javascript',
            'text/x-json'
        ):
            return json.loads(data)
        else:
            return data
437770
function getResponseHeaders(xhr) {
    let raw = xhr.getAllResponseHeaders();
    let parts = raw.replace(/\s+$/, '').split(/\n/);
    for (let i = 0; i < parts.length; i++) {
        parts[i] = parts[i].replace(/\r/g, '').replace(/^\s+/, '').replace(/\s+$/, '');
    }
    return parts;
}