Generates the appropriate response.
480977
def render_to_response(self, context, **response_kwargs):
        
        filename = os.path.basename(self.object.file.name)

        # Try to guess the content type of the given file
        content_type, _ = mimetypes.guess_type(self.object.file.name)
        if not content_type:
            content_type = 'text/plain'

        response = HttpResponse(self.object.file, content_type=content_type)
        response['Content-Disposition'] = 'attachment; filename={}'.format(filename)

        return response
119584
protected static function initResponse()
    {
        if (true === self::$registry->getParameter('doozr.kernel.debugging')) {
            self::$registry->getDebugbar()['time']->startMeasure('preparing-response', 'Preparing response');
        }

        self::$registry->setResponse(
            self::$registry->getContainer()->build(
                'Doozr_Response_'.self::$registry->getParameter('doozr.kernel.runtime.environment')
            )
        );

        if (true === self::$registry->getParameter('doozr.kernel.debugging')) {
            self::$registry->getDebugbar()['time']->stopMeasure('preparing-response');
        }

        // Important for bootstrap result
        return true;
    }
413138
def _render_response(self, value, system):
        
        super_call = super(DefaultResponseRendererMixin, self)._render_response
        try:
            method_name = 'render_{}'.format(system['request'].action)
        except (KeyError, AttributeError):
            return super_call(value, system)
        method = getattr(self, method_name, None)
        if method is not None:
            common_kw = self._get_common_kwargs(system)
            response = method(value, system, common_kw)
            system['request'].response = response
            return
        return super_call(value, system)
1242731
def _build_response(self, resp):
        """"""
        # rememberLogin
        # if self.method is 'LOGIN' and resp.json().get('code') == 200:
        #     cookiesJar.save_cookies(resp, NCloudBot.username)
        self.response.content = resp.content
        self.response.status_code = resp.status_code
        self.response.headers = resp.headers
1147817
def success_response(field=None, data=None, request_type=""):
    """"""
    data_out = {}
    data_out["status"] = "success"
    if field:
        data_out[field] = data
    print("{} request successful.".format(request_type))
    js = dumps(data_out, default=date_handler)
    return Response(js, status=200, mimetype='application/json')
852824
def after(self, context, exc=None):
		""""""
		
		duration = context._duration = round((time.time() - context._start_time) * 1000)  # Convert to ms.
		delta = unicode(duration)
		
		# Default response augmentation.
		if self.header:
			context.response.headers[self.header] = delta
		
		if self.log:
			self.log("Response generated in " + delta + " seconds.", extra=dict(
					duration = duration,
					request = id(context)
				))
259981
def generate_response(self, indexes, metrics, clusters=True):
        
        if self.clusters and clusters:
            return np.rec.fromarrays(
                (self.vocab[indexes], metrics, self.clusters.clusters[indexes]),
                names=("word", "metric", "cluster"),
            )
        else:
            return np.rec.fromarrays((self.vocab[indexes], metrics), names=("word", "metric"))
712279
async def make_response(self, request, response):
        """"""
        while iscoroutine(response):
            response = await response

        if isinstance(response, StreamResponse):
            return response

        if isinstance(response, str):
            return Response(text=response, content_type='text/html')

        if isinstance(response, bytes):
            return Response(body=response, content_type='text/html')

        return Response(text=json.dumps(response), content_type='application/json')
863095
def get_response(self):
        """"""
        request = getattr(requests, self.request_method, None)
        if request is None and self._request_method is None:
            raise ValueError("A effective http request method must be set")
        if self.request_url is None:
            raise ValueError(
                "Fatal error occurred, the class property \"request_url\" is"
                "set to None, reset it with an effective url of dingtalk api."
            )
        response = request(self.request_url, **self.kwargs)
        self.response = response
        return response
796312
def generate_token(self):
        """"""

        response = self._make_request()
        self.auth = response
        self.token = response['token']
389915
protected function send_response() {

        //Check that the returned values are valid
        try {
            if ($this->function->returns_desc != null) {
                $validatedvalues = external_api::clean_returnvalue($this->function->returns_desc, $this->returns);
            } else {
                $validatedvalues = null;
            }
        } catch (Exception $ex) {
            $exception = $ex;
        }

        if (!empty($exception)) {
            $response =  $this->generate_error($exception);
        } else {
            //We can now convert the response to the requested REST format
            if ($this->restformat == 'json') {
                $response = json_encode($validatedvalues);
            } else {
                $response = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
                $response .= '<RESPONSE>'."\n";
                $response .= self::xmlize_result($validatedvalues, $this->function->returns_desc);
                $response .= '</RESPONSE>'."\n";
            }
        }

        $this->send_headers();
        echo $response;
    }
1066937
public function buildResponse()
    {
        $return = array();
        foreach ($this->response as $k => $v)
        {
            $return[$k] = str_replace(array_map(function ($name){
                return '{' . $name . '}';
            }, array_keys($this->config['fake'])), array_values($this->config['fake']), $v);
        }

        return $return;
    }
975154
def render_to_response(self, context, indent=None):
        ""
        return self.get_json_response(self.convert_context_to_json(context, indent=indent))
803150
protected function interpretResponse()
    {
        $this->response = $this->interpreter->interpret($this->request, $this->rawResponse, $this->responseInformation);
    }
1088083
def csv_response(self):
        """"""
        def stream():
            """Create data stream generator"""
            stream_file = io.StringIO()
            csvwriter = csv.writer(stream_file, delimiter=',', quotechar='"')

            csvwriter.writerow(self.get_current_fields())

            for index, item in enumerate(self.items()):
                csvwriter.writerow([value for index, value in item.items()])
                stream_file.seek(0)
                data = stream_file.read()
                stream_file.seek(0)
                stream_file.truncate()
                yield data

        response = StreamingHttpResponse(stream(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename={}.csv".format(self.get_model_config().model_name.lower())
        return response
304892
def format_response(self, response):
        
        conversion = self.shell_ctx.config.BOOLEAN_STATES
        if response in conversion:
            if conversion[response]:
                return 'yes'
            return 'no'
        raise ValueError('Invalid response: input should equate to true or false')
397517
def render_to_response(self, context, **response_kwargs):
        
        return HttpResponse(json.dumps(context, cls=JSON_ENCODER), 
                            content_type='application/json',
                            **response_kwargs)