Internal Error - utf8 value in request - wsgi-python(django)

#1
Hi there,
at the moment I use Litespeed 5.4.11 - Cpanel v92.0.6 - Cloudlinux 7.9.
I deployed a Django project with Cloudlinux Python App interface and its work like a charm, except during handling utf8 requests
for example when I make a request like :
domain.com/تست
i face with this error:

Code:
Internal Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

and raised this error at app level log:

Code:
2021-02-19 13:55:59.137486 [ERROR] [UID:2001][6653] wsgiAppHandler pApp->start_response() return NULL.
Traceback (most recent call last):
  File "/home1/user/virtualenv/name/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 130, in __call__
    set_script_prefix(get_script_name(environ))
  File "/home1/user/virtualenv/name/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 175, in get_script_name
    script_url = get_bytes_from_wsgi(environ, 'SCRIPT_URL', '') or get_bytes_from_wsgi(environ, 'REDIRECT_URL', '')
  File "/home1/user/virtualenv/name/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 200, in get_bytes_from_wsgi
    return value.encode('iso-8859-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 6-13: ordinal not in range(256)
but there is not any error log at the webserver level.
when I switch the webserver to Apache, the problem will be solved
I think it's relevant with Python Bug that fixed at LSWS 5.4.3 release:

Code:
BUGFIX Fixed a problem with utf-8 characters in request URLs for Python applications.
sorry for my bad English <3
 

mistwang

LiteSpeed Staff
#2
Hi,

Thanks for the bug report.
Looks it need some update to the lswsgi binary to apply correct encoding. Please try the following commands
Code:
wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.9.tgz
tar xvfz wsgi-lsapi-1.9.tgz
cd wsgi-lsapi-1.9
/opt/alt/python38/bin/python3 configure.py
sed -i -e "s#/opt/rh/devtoolset-7/root/usr/bin/##" Makefile
make 1>/dev/null 2>&1
cp lswsgi /opt/alt/python38/bin/
see if it fixes the problem or not.
 
#5
hi

i used below command for fix this problem but it didn't fix
after make command the file "wsgi" created
and when i press ./l'wsgi --version the result is 1.8.0 i try this solution for 10 times

Hi,

Thanks for the bug report.
Looks it need some update to the lswsgi binary to apply correct encoding. Please try the following commands
Code:
wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.9.tgz
tar xvfz wsgi-lsapi-1.9.tgz
cd wsgi-lsapi-1.9
/opt/alt/python38/bin/python3 configure.py
sed -i -e "s#/opt/rh/devtoolset-7/root/usr/bin/##" Makefile
make 1>/dev/null 2>&1
cp lswsgi /opt/alt/python38/bin/
see if it fixes the problem or not.
 
Top