@@ -86,7 +86,9 @@ def _get_ip(asgi_scope: "Any") -> str:
8686 return asgi_scope .get ("client" )[0 ]
8787
8888
89- def _get_request_data (asgi_scope : "Any" ) -> "Dict[str, Any]" :
89+ def _get_request_data (
90+ asgi_scope : "Any" , path_includes_root_path : "bool" = True
91+ ) -> "Dict[str, Any]" :
9092 """
9193 Returns data related to the HTTP request from the ASGI scope.
9294 """
@@ -101,7 +103,10 @@ def _get_request_data(asgi_scope: "Any") -> "Dict[str, Any]":
101103 request_data ["query_string" ] = _get_query (asgi_scope )
102104
103105 request_data ["url" ] = _get_url (
104- asgi_scope , "http" if ty == "http" else "ws" , headers .get ("host" )
106+ asgi_scope ,
107+ "http" if ty == "http" else "ws" ,
108+ headers .get ("host" ),
109+ path_includes_root_path = path_includes_root_path ,
105110 )
106111
107112 client = asgi_scope .get ("client" )
@@ -111,7 +116,9 @@ def _get_request_data(asgi_scope: "Any") -> "Dict[str, Any]":
111116 return request_data
112117
113118
114- def _get_request_attributes (asgi_scope : "Any" ) -> "dict[str, Any]" :
119+ def _get_request_attributes (
120+ asgi_scope : "Any" , path_includes_root_path : "bool" = True
121+ ) -> "dict[str, Any]" :
115122 """
116123 Return attributes related to the HTTP request from the ASGI scope.
117124 """
@@ -132,7 +139,10 @@ def _get_request_attributes(asgi_scope: "Any") -> "dict[str, Any]":
132139 attributes ["http.query" ] = query
133140
134141 url_without_query_string = _get_url (
135- asgi_scope , "http" if ty == "http" else "ws" , headers .get ("host" )
142+ asgi_scope ,
143+ "http" if ty == "http" else "ws" ,
144+ headers .get ("host" ),
145+ path_includes_root_path = path_includes_root_path ,
136146 )
137147 query_string = _get_query (asgi_scope )
138148 attributes ["url.full" ] = (
0 commit comments