returns a rack response with the given object encoded in the appropriate format for the requests.

 arguments are in the order of what tends to vary most frequently
 rather than rack's way, so headers come last
964202
def format_response(status, body_object, headers={})
      if status == 204
        body = ''
      else
        body = case response_media_type
        when 'application/json'
          JSON.pretty_generate(body_object)
        when 'application/x-www-form-urlencoded'
          URI.encode_www_form(body_object)
        when 'application/xml'
          body_object.to_s
        when 'text/plain'
          body_object
        else
          # :nocov:
          raise NotImplementedError, "unsupported response media type #{response_media_type}"
          # :nocov:
        end
      end
      [status, headers.merge({'Content-Type' => response_media_type}), [body]]
    end
1183929
def get_response(self):
        
        res = IODWriteMultipleRes()
        for field in ["seqNum", "ARUUID", "API", "slotNumber",
                      "subslotNumber", "index"]:
            res.setfieldval(field, self.getfieldval(field))

        # append all block response
        res_blocks = []
        for block in self.getfieldval("blocks"):
            res_blocks.append(block.get_response())
        res.setfieldval("blocks", res_blocks)
        return res
174229
def _DeserializeResponse(self, payload):
        
        # Strip off the status line.
        status_line, payload = payload.split('\n', 1)
        _, status, _ = status_line.split(' ', 2)

        # Parse the rest of the response.
        parser = email_parser.Parser()
        msg = parser.parsestr(payload)

        # Get the headers.
        info = dict(msg)
        info['status'] = status

        # Create Response from the parsed headers.
        content = msg.get_payload()

        return http_wrapper.Response(info, content, self.__batch_url)
889966
def extract_header_value(response, key)
        response.headers[key].class == Array ? response.headers[key].first.to_i : response.headers[key].to_i 
      end
629698
def do_response(self, response_args=None, request=None, **kwargs):
        

        links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs['hrefs']]

        _response = JRD(subject=kwargs['subject'], links=links)

        info = {
            'response': _response.to_json(),
            'http_headers': [('Content-type', 'application/json')]
        }

        return info
1244159
function format(response) {

		var newObj = [];
		var objects = _.get(response, 'objects') || response;
		
		if (objects) {

			// check if objects is an array
			if (Array.isArray(objects)) {
				_.forEach(objects, function(obj) {
					newObj.push(expandFields(formatProp(obj)));
				});
			}
			else {
				newObj = expandFields(formatProp(objects));
			}
			return newObj;
		}

		// if no objects return the raw response
		return response;
	}
1248415
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    parameters['response'] = client_message.read_int()
    return parameters
297831
def encode(response)
      [200,
       { Rack::CONTENT_TYPE => 'text/html',
         Rack::CONTENT_LENGTH => response.size.to_s },
       [response]]
    end
1108912
def getheader(self, name, default=None):
        
        return self.response.headers.get(name, default)
1331623
def decode_produce_response(cls, response):
        
        return [
            kafka.structs.ProduceResponsePayload(topic, partition, error, offset)
            for topic, partitions in response.topics
            for partition, error, offset in partitions
        ]
1112186
function getOperationResponseHeaders(operation) {
    var headers = [];

    if (operation) {
        _.each(operation.responses, function(response, responseCode) {
            // Convert responseCode to a numeric value for sorting ("default" comes last)
            responseCode = parseInt(responseCode) || 999;

            _.each(response.headers, function(header, name) {
                // We only care about headers that have a default value defined
                if (header.default !== undefined) {
                    headers.push({
                        order: responseCode,
                        name: name.toLowerCase(),
                        value: header.default
                    });
                }
            });
        });
    }

    return _.sortBy(headers, 'order');
}
1165544
def make_response(status, headers, payload, environ):
    
    return Response(body=payload, status=int(status.split()[0]),
                    headers=headers)
773444
def build_response_object(session_end = true)
      @response = Hash.new
      @response[:outputSpeech] = @speech unless @speech.nil?
      @response[:directives] = @directives unless @directives.empty?
      @response[:card] = @card unless @card.nil?
      @response[:reprompt] = @reprompt unless session_end && @reprompt.nil?
      @response[:shouldEndSession] = session_end
      @response
    end
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
701
def make_json_response(rv):
    
    # Tuple of (response, status, headers)
    rv, status, headers = normalize_response_value(rv)

    # JsonResponse
    if isinstance(rv, JsonResponse):
        return rv

    # Data
    return JsonResponse(rv, status, headers)
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
1095275
def headers(headers={}):
    
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            resp = make_response(f(*args, **kwargs))
            h = resp.headers
            for header, value in headers.items():
                h[header] = value
            return resp
        return decorated_function
    return decorator