mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Use a WSGI "bytes-as-unicode" string for PATH_INFO under Python 3.
This commit is contained in:
parent
ca35dc7335
commit
fa7fd6fed0
@ -8,8 +8,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from gunicorn.six import (unquote, string_types, binary_type, reraise,
|
from gunicorn.six import unquote_to_wsgi_str, string_types, binary_type, reraise
|
||||||
text_type)
|
|
||||||
from gunicorn import SERVER_SOFTWARE
|
from gunicorn import SERVER_SOFTWARE
|
||||||
import gunicorn.util as util
|
import gunicorn.util as util
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ def create(req, sock, client, server, cfg):
|
|||||||
path_info = req.path
|
path_info = req.path
|
||||||
if script_name:
|
if script_name:
|
||||||
path_info = path_info.split(script_name, 1)[1]
|
path_info = path_info.split(script_name, 1)[1]
|
||||||
environ['PATH_INFO'] = unquote(path_info)
|
environ['PATH_INFO'] = unquote_to_wsgi_str(path_info)
|
||||||
environ['SCRIPT_NAME'] = script_name
|
environ['SCRIPT_NAME'] = script_name
|
||||||
|
|
||||||
environ.update(proxy_environ(req))
|
environ.update(proxy_environ(req))
|
||||||
|
|||||||
@ -387,7 +387,10 @@ if PY3:
|
|||||||
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
unquote = urllib.parse.unquote
|
def unquote_to_wsgi_str(string):
|
||||||
|
return _unquote_to_bytes(string).decode('latin-1')
|
||||||
|
|
||||||
|
_unquote_to_bytes = urllib.parse.unquote_to_bytes
|
||||||
urlsplit = urllib.parse.urlsplit
|
urlsplit = urllib.parse.urlsplit
|
||||||
urlparse = urllib.parse.urlparse
|
urlparse = urllib.parse.urlparse
|
||||||
|
|
||||||
@ -402,4 +405,4 @@ else:
|
|||||||
urlparse = orig_urlparse.urlparse
|
urlparse = orig_urlparse.urlparse
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
unquote = urllib.unquote
|
unquote_to_wsgi_str = urllib.unquote
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user