Generates server response.
426880
def respond(self, output):
        """"""
        response = {'exit_code': output.code,
                    'command_output': output.log}

        self.send_response(200)

        self.send_header('Content-type', 'application/json')
        self.end_headers()

        self.wfile.write(bytes(json.dumps(response), "utf8"))
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
1089269
function response()
    {
        if (!$this->response) {
            $settings = new DataParseResponsePhp;
            $response = new HttpResponse(
                new BuildHttpResponse( BuildHttpResponse::parseWith($settings) )
            );

            $this->response = $response;
        }

        return $this->response;
    }
15140
def render_to_response(self, context):
        
        self.setup_forms()
        return TemplateResponse(
            self.request, self.form_template,
            context, current_app=self.admin_site.name)
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')
245792
def build_final_response(request, meta, result, menu, hproject, proxyMode, context):
    """"""

    if 'no_template' in meta and meta['no_template']:  # Just send the json back
        return HttpResponse(result)

    # TODO this breaks pages not using new template
    # Add sidebar toggler if plugit did not add by itself
    # if not "sidebar-toggler" in result:
    #     result = "<div class=\"menubar\"><div class=\"sidebar-toggler visible-xs\"><i class=\"ion-navicon\"></i></div></div>" + result

    # render the template into the whole page
    if not settings.PIAPI_STANDALONE:
        return render_to_response('plugIt/' + hproject.get_plugItTemplate_display(),
                                  {"project": hproject,
                                   "plugit_content": result,
                                   "plugit_menu": menu,
                                   'context': context},
                                  context_instance=RequestContext(request))

    if proxyMode:  # Force inclusion inside template
        return render_to_response('plugIt/base.html',
                                  {'plugit_content': result,
                                   "plugit_menu": menu,
                                   'context': context},
                                  context_instance=RequestContext(request))

    renderPlugItTemplate = 'plugItBase.html'
    if settings.PIAPI_PLUGITTEMPLATE:
        renderPlugItTemplate = settings.PIAPI_PLUGITTEMPLATE

    return render_to_response('plugIt/' + renderPlugItTemplate,
                              {"plugit_content": result,
                               "plugit_menu": menu,
                               'context': context},
                              context_instance=RequestContext(request))
962040
def _server_begin_response_callback(self, response: Response):
        ''''''
        self._item_session.response = response

        if self._cookie_jar:
            self._cookie_jar.extract_cookies(response, self._item_session.request)

        action = self._result_rule.handle_pre_response(self._item_session)
        self._file_writer_session.process_response(response)

        return action == Actions.NORMAL
414500
def render_to_response(self, obj, **response_kwargs):
        
        return HttpResponse(self.serialize(obj), content_type='application/json', **response_kwargs)
1005090
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (class_exists(StandardDebugBar::class)) {
            DebugBar::enable();

            DebugBar::initPDO(DB::connection()->getPdo());

            $response = $handler->handle($request);

            if ($this->shouldSendDataOnNextPage($response)) {
                DebugBar::stackData();
            } elseif ($this->shouldSendDataInHeaders($request)) {
                DebugBar::sendDataInHeaders();
            }

            return $response;
        }

        return $handler->handle($request);
    }
451849
protected void sendServerResponse(HttpMessage response) {
        designer.http().server(httpServer).send()
                .response(response.getStatusCode())
                .message(response);
    }
1112226
def __parseResponseServer(self):
        """"""
        
        self.__logger.debug(Sitools2Abstract.getBaseUrl(self) + SITools2Instance.PROJECTS_URI)        
        result = Util.retrieveJsonResponseFromServer(Sitools2Abstract.getBaseUrl(self) + SITools2Instance.PROJECTS_URI)
        isSuccess = result['success']
        if isSuccess:            
            data = result['data']
            self.__logger.debug(data)
            for i, dataItem in enumerate(data):
                project = Project(Sitools2Abstract.getBaseUrl(self), dataItem)
                self.__projects.append(project)
        else:
            raise Sitools2Exception("Error when loading the server response")
293751
def server
    reply = json_get(target, '/login', key_style)
    return reply if reply && (reply[:prompts] || reply['prompts'])
    raise BadResponse, "Invalid response from target #{target}"
  end
177675
def response_builder(self, response):
        '''
        '''
        try:
            r = response.json()
            result = r['query']['results']
            response = {
                'num_result': r['query']['count'] ,
                'result': result
            }
        except (Exception,) as e:
            print(e)
            return response.content

        return response
934817
public function sendResponse()
    {
        $this->sendHeaders();

        if ($this->isException() && $this->renderExceptions())
        {
            $exceptions = '';
            foreach ($this->getException() as $e)
            {
                $exceptions .= $e->__toString() . "\n";
            }
            echo $exceptions;
            return;
        }

        $this->outputBody();
    }
1359384
public function respond()
    {
        // Make sure there always is a response
        if (null === $this->result)
        {
            $this->result = new Result;
            $this->result->setResponse(new Error(500, "No output produced"));
        }
        
        // Close and log all script output that hasn't been cleaned yet
        $this->endAllOutputBuffers($this->target_ob_level);

        // Add Content-Type mime header
        $response = $this->result->getResponse();
        $mime = $response->getMimeTypes();
        if (empty($mime))
        {
            $mime = Request::cli() ? "text/plain" : "text/html";
        }
        elseif (is_array($mime))
        {
            $types = $mime;
            $mime = null;
            foreach ($types as $type)
            {
                if ($this->request->accepts($type))
                {
                    $mime = $type;
                    break;
                }
            }
        }

        // If mime is not accepted, return a 406 response
        if (empty($mime) || !$this->request->accepts($mime))
        {
            $mime = 'text/html';
            $this->result->setResponse(new Error(406, "Not Acceptable", 'No acceptable response can be offered'));
        }

        // Execute hooks
        $hook_params = [
            'responder' => $this,
            'request' => $this->request,
            'mime' => $mime,
        ];

        $hook_params = Hook::execute('Wedeto.HTTP.Responder.Respond', $hook_params);

        // Check if mime type was updated
        if (is_string($hook_params['mime']))
            $mime_charset = $hook_params['mime'];

        $mime_charset = $mime;
        $tp = new FileType('', $mime);
        if ($tp->isPlainText())
            $mime_charset .= '; charset=utf-8';

        // Set mime type
        $this->setHeader('Content-Type', $mime_charset);

        // Add headers from response to the final response
        foreach ($this->result->getAllHeaders() as $key => $value)
            $this->setHeader($key, $value);

        // Store the response code
        $this->setResponseCode($response->getStatusCode());

        // All preparational work is done, time to send stuff to the client
        $this->doOutput($mime);
    }
11486
function serverResponseToRESPONSE (response) {
	try {
		const obj = JSON.parse(response);
		if (obj.result === RESPONSE_UNKNOWN) {
			return RESPONSE_UNKNOWN;
		} else {
			return obj.result.result;
		}
	} catch (e) {
		return RESPONSE_INVALID;
	}
}
612470
protected function _buildAndExecuteProxyResponse()
    {
        if($this->_responseModifier)
        {
          $data = call_user_func_array($this->_responseModifier, array(&$this->_responseBody, &$this->_responseHeaders));
        }

        $this->_generateProxyResponseHeaders();

        $this->_output($this->_responseBody);
    }