Postprocess the websocket acting on the response.

        Arguments:
            response: The response after the websocket is finalized.
            webcoket_context: The websocket context, optional as Flask
                omits this argument.
326226
async def postprocess_websocket(
        self,
        response: Optional[Response],
        websocket_context: Optional[WebsocketContext]=None,
    ) -> Response:
        
        websocket_ = (websocket_context or _websocket_ctx_stack.top).websocket
        functions = (websocket_context or _websocket_ctx_stack.top)._after_websocket_functions
        blueprint = websocket_.blueprint
        if blueprint is not None:
            functions = chain(functions, self.after_websocket_funcs[blueprint])
        functions = chain(functions, self.after_websocket_funcs[None])

        for function in functions:
            response = await function(response)

        session_ = (websocket_context or _request_ctx_stack.top).session
        if not self.session_interface.is_null_session(session_):
            if response is None and isinstance(session_, SecureCookieSession) and session_.modified:
                self.logger.exception(
                    "Secure Cookie Session modified during websocket handling. "
                    "These modifications will be lost as a cookie cannot be set."
                )
            else:
                await self.save_session(session_, response)
        return response
740633
def _process_response(self, response):
        
        assert self._state == self._STATE_RUNNING, "Should be running if processing response"
        cols = None
        data = []
        for r in response:
            if not cols:
                cols = [(f, r._fields[f].db_type) for f in r._fields]
            data.append([getattr(r, f) for f in r._fields])
        self._data = data
        self._columns = cols
        self._state = self._STATE_FINISHED
1255261
def _handle_response(response, **kwargs) -> XMLResponse:
        
        if not response.encoding:
            response.encoding = DEFAULT_ENCODING

        return response
702822
async def finalize_request(
        self,
        result: ResponseReturnValue,
        request_context: Optional[RequestContext]=None,
        from_error_handler: bool=False,
    ) -> Response:
        
        response = await self.make_response(result)
        try:
            response = await self.process_response(response, request_context)
            await request_finished.send(self, response=response)
        except Exception:
            if not from_error_handler:
                raise
            self.logger.exception('Request finalizing errored')
        return response
948072
function afterProcessReq(request, response) {
    defaults.afterExecuteOfflineItem(response, request.payload);
    return processReqs(utils.storage.get('queue'));
  }
1185591
def process_response(self, request, response):
        
        process = False

        # Don't do anything for unsecure requests, unless DEBUG is on
        if not self.allow_http and not request.is_secure():
            return response

        if response.status_code == UNAUTHORIZED:
            pass
        elif response.status_code == FOUND:
            location = urllib_parse.urlparse(response['Location'])
            if location.path != settings.LOGIN_URL:
                # If it wasn't a redirect to the login page, we don't touch it.
                return response
            elif not self.is_agent_a_robot(request):
                # We don't touch requests made in order to be shown to humans.
                return response

        realm = getattr(settings, 'BASIC_AUTH_REALM', request.META.get('HTTP_HOST', 'restricted'))
        
        if response.status_code == FOUND:
            response = self.unauthorized_view(request)

        authenticate = response.get('WWW-Authenticate', None)
        if authenticate:
            authenticate = 'Basic realm="%s", %s' % (realm, authenticate)
        else:
            authenticate = 'Basic realm="%s"' % realm
        response['WWW-Authenticate'] = authenticate

        return response
69628
def execute(self):
        
        es = connections.get_connection(self._using)

        self._response = self._response_class(
            self,
            es.update_by_query(
                index=self._index,
                body=self.to_dict(),
                **self._params
            )
        )
        return self._response
678541
async def handle_request(self, request: Request) -> Response:
        
        # Get handler
        try:
            try:
                self._set_ctx(request)
                handler = self.router.get_handler_for_request(request)
                request.app = self
                response = await handler(request)
                response.app = self
            except ResponseError as r:
                parser = app_parsers.get(request.content_type, None)

                # Content-Type of an error response will be the same as the incoming request
                # unless a parser for that content type is not found.
                if not parser:
                    content_type = r.content_type
                    if not content_type:
                        content_type = self.default_content_type
                else:
                    content_type = request.content_type
                response = Response(
                    headers=r.headers, correlation_id=r.correlation_id, body=r.body,
                    status=r.status, content_type=content_type
                )
                response.app = self
                if r.log:
                    exc_info = sys.exc_info()
                    self.logger.log_exception(request, exc_info, level='warning')
            # invoke serialization (json) to make sure it works
            _ = response.body

        except CancelledError:
            # This error can happen if a client closes the connection
            # The response shouldnt really ever be used
            return None

        except asyncio.TimeoutError:
            response = Response(status=HTTPStatus.GATEWAY_TIMEOUT,
                                body={'message': 'Gateway Timeout'})
            response.app = self

        except NackMePleaseError:
            """ See message where this error is defined """
            raise

        except Exception:
            exc_info = sys.exc_info()
            self.logger.log_exception(request, exc_info)
            response = Response(status=HTTPStatus.INTERNAL_SERVER_ERROR,
                                body={'message': 'Server Error'})
            response.app = self
        if not response.correlation_id:
            response.correlation_id = request.correlation_id

        if self._cors_handler is not None:
            self._cors_handler.add_cors_headers(request, response)

        # add default headers
        response.headers = {**self.default_headers, **response.headers}

        return response
83144
def post_parse_response(self, response, **kwargs):
        

        if "scope" not in response:
            try:
                _key = kwargs['state']
            except KeyError:
                pass
            else:
                if _key:
                    item = self.get_item(oauth2.AuthorizationRequest,
                                         'auth_request', _key)
                    try:
                        response["scope"] = item["scope"]
                    except KeyError:
                        pass
        return response
996369
async def dispatch_websocket(
        self, websocket_context: Optional[WebsocketContext]=None,
    ) -> None:
        
        websocket_ = (websocket_context or _websocket_ctx_stack.top).websocket
        if websocket_.routing_exception is not None:
            raise websocket_.routing_exception

        handler = self.view_functions[websocket_.url_rule.endpoint]
        return await handler(**websocket_.view_args)
1153365
def _handle_response(response, command, id_xpath='./id', **kwargs):
    
    _response_switch = {
        'insert': ModifyResponse,
        'replace': ModifyResponse,
        'partial-replace': ModifyResponse,
        'update': ModifyResponse,
        'delete': ModifyResponse,
        'search-delete': SearchDeleteResponse,
        'reindex': Response,
        'backup': Response,
        'restore': Response,
        'clear': Response,
        'status': StatusResponse,
        'search': SearchResponse,
        'retrieve': ListResponse,
        'similar': ListResponse,
        'lookup': LookupResponse,
        'alternatives': AlternativesResponse,
        'list-words': WordsResponse,
        'list-first': ListResponse,
        'list-last': ListResponse,
        'retrieve-last': ListResponse,
        'retrieve-first': ListResponse,
        'show-history': None,
        'list-paths': ListPathsResponse,
        'list-facets': ListFacetsResponse}
    try:
        request_class = _response_switch[command]
    except KeyError:
        request_class = Response
    return request_class(response, id_xpath, **kwargs)
295873
async def preprocess_websocket(
        self, websocket_context: Optional[WebsocketContext]=None,
    ) -> Optional[ResponseReturnValue]:
        
        websocket_ = (websocket_context or _websocket_ctx_stack.top).websocket
        blueprint = websocket_.blueprint
        processors = self.url_value_preprocessors[None]
        if blueprint is not None:
            processors = chain(processors, self.url_value_preprocessors[blueprint])  # type: ignore
        for processor in processors:
            processor(websocket_.endpoint, websocket_.view_args)

        functions = self.before_websocket_funcs[None]
        if blueprint is not None:
            functions = chain(functions, self.before_websocket_funcs[blueprint])  # type: ignore
        for function in functions:
            result = await function()
            if result is not None:
                return result
        return None
615799
def _handle_post(self):
        
        der = request.body.read()
        ocsp_request = self._parse_ocsp_request(der)
        return self._build_http_response(ocsp_request)
1003825
async def process(client: Client, transaction_signed_raw: str) -> ClientResponse:
    
    return await client.post(MODULE + '/process', {'transaction': transaction_signed_raw}, rtype=RESPONSE_AIOHTTP)
912295
def _handle_response(self, response):
        
        if response.status_code == requests.codes.ok or response.status_code == requests.codes.created:
            try:
                return response.json()
            except ValueError:
                return response
        else:
            return self._handle_failed_response(response)
1286042
def _handle_response(self):
        
        content = self.cache['restbase']['info']['content-type']
        if content.startswith('text/html'):
            html = self.cache['restbase']['response']
            if isinstance(html, bytes):
                html = html.decode('utf-8')
            self.data['html'] = html
            return

        response = self._load_response('restbase')

        http_status = self.cache['restbase']['info']['status']
        if http_status == 404:
            raise LookupError(self.cache['restbase']['query'])

        if self.params.get('endpoint') == '/page/':
            msg = "RESTBase /page/ entry points: %s" % response.get('items')
            utils.stderr(msg)
            del self.cache['restbase']
            return

        return response
884263
def _after_request(self, response):
        
        # Do not trace if the url is blacklisted
        if utils.disable_tracing_url(flask.request.url, self.blacklist_paths):
            return response

        try:
            tracer = execution_context.get_opencensus_tracer()
            tracer.add_attribute_to_current_span(
                HTTP_STATUS_CODE,
                str(response.status_code))
        except Exception:  # pragma: NO COVER
            log.error('Failed to trace request', exc_info=True)
        finally:
            return response