Pack the provided data into a Response
172678
def pack(cls, data):
        ''''''
        return struct.pack('>ll', len(data) + 4, cls.FRAME_TYPE) + data
1213682
def unpack(cls, data):
        
        header, data = APPHeader.unpack(data)

        if len(data) < header.payload_length:
            raise ProtocolViolation("Payload too small")
        payload = data[:header.payload_length]
        body = cls()
        body._header = header
        body._payload = payload
        return body, data[header.payload_length:]
794084
def _loads(self, response):
        
        return bser.loads(
            response,
            True,
            value_encoding=encoding.get_local_encoding(),
            value_errors=encoding.default_local_errors,
        )
1138299
def _append(self, signature, fields=(), response=None):
        
        self.packer.pack_struct(signature, fields)
        self.output_buffer.chunk()
        self.output_buffer.chunk()
        self.responses.append(response)
866561
def __pack_message(operation, data):
    
    request_id = random.randint(-2 ** 31 - 1, 2 ** 31)
    message = struct.pack("<i", 16 + len(data))
    message += struct.pack("<i", request_id)
    message += __ZERO  # responseTo
    message += struct.pack("<i", operation)
    return (request_id, message + data)
1219396
def dump_data(request):
    
    # Try to grab app_label data
    app_label = request.GET.get('app_label', [])
    if app_label:
        app_label = app_label.split(',')
    return dump_to_response(request, app_label=app_label,
                            exclude=settings.SMUGGLER_EXCLUDE_LIST)
1165544
def make_response(status, headers, payload, environ):
    
    return Response(body=payload, status=int(status.split()[0]),
                    headers=headers)
656807
def ProcessResponse(self, client_id, response):
    """"""
    precondition.AssertType(client_id, Text)
    downsampled = rdf_client_stats.ClientStats.Downsampled(response)

    if data_store.AFF4Enabled():
      urn = rdf_client.ClientURN(client_id).Add("stats")

      with aff4.FACTORY.Create(
          urn, aff4_stats.ClientStats, token=self.token, mode="w") as stats_fd:
        # Only keep the average of all values that fall within one minute.
        stats_fd.AddAttribute(stats_fd.Schema.STATS, downsampled)

    if data_store.RelationalDBEnabled():
      data_store.REL_DB.WriteClientStats(client_id, downsampled)

    return downsampled
193224
function createResponseData(instruction, templates){
  instruction.map(function(inst){
    if(!templates[inst.key]){return log.templateNotSpecified(inst.key);}
    var data = [];
    for(var j=0;j<inst.amount;j++){
      data.push(cloneAndInvoke(templates[inst.key]));
    }
    inst.location.splice.apply(inst.location, [inst.index, 1].concat(data));
  });
}
401037
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    response_size = client_message.read_int()
    response = []
    for _ in range(0, response_size):
        response_item = client_message.read_data()
        response.append(response_item)
    parameters['response'] = ImmutableLazyDataList(response, to_object)
    return parameters
266095
function prepareData(items, with_timestamps, with_ns) {
    var data = {
        request: 'sender data',
        data: items
    };

    if (with_timestamps) {
        var ts = Date.now() / 1000;
        data.clock = ts | 0;

        if (with_ns) {
            data.ns = (ts % 1) * 1000 * 1000000 | 0;
        }
    }

    var payload = new Buffer(JSON.stringify(data), 'utf8'),
        header  = new Buffer(5 + 4); // ZBXD\1 + packed payload.length

    header.write('ZBXD\x01');
    header.writeInt32LE(payload.length, 5);
    return Buffer.concat([header, new Buffer('\x00\x00\x00\x00'), payload]);
}
828627
def load_attributes_from_response(response)
      if (response['Transfer-Encoding'] == 'chunked' || (!response['Content-Length'].blank? && response['Content-Length'] != "0")) && !response.body.nil? && response.body.strip.size > 0
        load( self.class.format.decode(response.body)[self.class.element_name] )
        #fix double nested items .. active resource SUCKS soooo bad
        if self.respond_to?(:items)
          new_items = []
          self.items.each { |item| new_items << item.attributes.first[1] }
          self.items = new_items
        end
        @persisted = true
      end
    end
676517
def transform_response(response, options = {})
      # Now unpack the response into the data types.
      inner = response.delete("response")
      objects = unpack inner, options
      # Unpack pagination as a special case.
      if response.has_key?("pagination")
        paginated_response objects, response
      else
        objects
      end
    end
124617
function buildResponse(data) {
    var response = {};
    response.totalItems = data.length;
    response.itemsPerPage = itemsPerPage;
    response.totalPages = itemsPerPage === null ? 1 : Math.ceil(data.length / itemsPerPage);
    response.currentPage = itemsPerPage === null ? 1 : currentPage;
    response.data = itemsPerPage === null ? data : data.slice(itemsPerPage * (currentPage - 1), itemsPerPage);

    return response;
}
909727
def from_response(cls, response):
        
        hash_key = None
        range_key = None
        # KeySchema may not be in the response if the TableStatus is DELETING.
        if 'KeySchema' in response:
            attrs = dict(((d['AttributeName'],
                           DynamoKey(d['AttributeName'], d['AttributeType']))
                          for d in response['AttributeDefinitions']))
            hash_key = attrs[response['KeySchema'][0]['AttributeName']]
            if len(response['KeySchema']) > 1:
                range_key = attrs[response['KeySchema'][1]['AttributeName']]

        indexes = []
        for idx in response.get('LocalSecondaryIndexes', []):
            indexes.append(LocalIndex.from_response(idx, attrs))
        global_indexes = []
        for idx in response.get('GlobalSecondaryIndexes', []):
            global_indexes.append(GlobalIndex.from_response(idx, attrs))

        table = cls(
            name=response['TableName'],
            hash_key=hash_key,
            range_key=range_key,
            indexes=indexes,
            global_indexes=global_indexes,
            throughput=Throughput.from_response(
                response['ProvisionedThroughput']),
            status=response['TableStatus'],
            size=response['TableSizeBytes'],
        )
        table.response = response
        return table
926732
def pack_into(self, buf, offset, write_payload):
    
    return self._get_framed(buf, offset, write_payload)
185144
def packed_data(self):
        """"""
        # Pack the header
        scp_header = struct.pack("<2H", self.cmd_rc, self.seq)

        # Potential loop intentionally unrolled
        if self.arg1 is not None:
            scp_header += struct.pack('<I', self.arg1)
        if self.arg2 is not None:
            scp_header += struct.pack('<I', self.arg2)
        if self.arg3 is not None:
            scp_header += struct.pack('<I', self.arg3)

        # Return the SCP header and the rest of the data
        return scp_header + self.data