@@ -11,7 +11,7 @@ use itertools::Itertools;
11
11
use percent_encoding:: percent_decode_str;
12
12
use pyo3:: {
13
13
prelude:: * ,
14
- types:: { IntoPyDict , PyDict } ,
14
+ types:: { IntoPyDict , PyBytes , PyDict } ,
15
15
} ;
16
16
use std:: borrow:: Cow ;
17
17
use std:: net:: SocketAddr ;
@@ -39,7 +39,7 @@ fn run_callback(
39
39
. uri
40
40
. path_and_query ( )
41
41
. map_or_else ( || ( "" , "" ) , |pq| ( pq. path ( ) , pq. query ( ) . unwrap_or ( "" ) ) ) ;
42
- let path = percent_decode_str ( path_raw) . decode_utf8 ( ) . unwrap ( ) ;
42
+ let path = percent_decode_str ( path_raw) . collect_vec ( ) ;
43
43
let version = match parts. version {
44
44
Version :: HTTP_10 => "HTTP/1" ,
45
45
Version :: HTTP_11 => "HTTP/1.1" ,
@@ -75,7 +75,10 @@ fn run_callback(
75
75
environ. set_item ( pyo3:: intern!( py, "SERVER_PORT" ) , server. 1 ) ?;
76
76
environ. set_item ( pyo3:: intern!( py, "REMOTE_ADDR" ) , client) ?;
77
77
environ. set_item ( pyo3:: intern!( py, "REQUEST_METHOD" ) , parts. method . as_str ( ) ) ?;
78
- environ. set_item ( pyo3:: intern!( py, "PATH_INFO" ) , path) ?;
78
+ environ. set_item (
79
+ pyo3:: intern!( py, "PATH_INFO" ) ,
80
+ PyBytes :: new_bound ( py, & path) . call_method1 ( pyo3:: intern!( py, "decode" ) , ( pyo3:: intern!( py, "latin1" ) , ) ) ?,
81
+ ) ?;
79
82
environ. set_item ( pyo3:: intern!( py, "QUERY_STRING" ) , query_string) ?;
80
83
environ. set_item ( pyo3:: intern!( py, "wsgi.url_scheme" ) , scheme) ?;
81
84
environ. set_item ( pyo3:: intern!( py, "wsgi.input" ) , Py :: new ( py, WSGIBody :: new ( rt, body) ) ?) ?;
0 commit comments