Пример #1
0
def test_get_asgi_request_full_url(scope, expected_value):
    request = Request.incoming(scope["method"], scope["raw_path"],
                               scope["query_string"], scope["headers"])
    request.scope = scope

    full_url = get_request_url(request)
    assert full_url == expected_value
Пример #2
0
    def produce_response(self, request: Request, exc: Exception) -> Response:
        tb = traceback.format_exception(exc.__class__, exc, exc.__traceback__)
        info = ""
        for item in tb:
            info += f"<li><pre>{html.escape(item)}</pre></li>"

        content = HtmlContent(
            self._error_page_template.format_map({
                "info":
                info,
                "exctype":
                exc.__class__.__name__,
                "excmessage":
                str(exc),
                "method":
                request.method,
                "path":
                request.url.value.decode(),
                "full_url":
                get_request_url(request),
            }))

        return Response(500, content=content)