Some http response header without English (using utf-8) has encoding error. original text (2. 핵심정보를 담은 발표 형성평가 5월 19일) I uploaded this text on server.
and I responded to server with get function. (requests.get())
but I got this text (2. íµì¬ì 보를 ë´ì ë°í íì±íê° 5ì 19ì¼) from http response header.
I converted the text has encoding error to ascii to utf8 converter. It converts successfully. maybe requests package gets http response header with ascii encoding.
EDIT
I tried this code req.encoding = 'utf-8' but this code didn't work.
code:
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
'Content-type': 'text/plain; charset=utf-8'
}
req = requests.get(link, headers=headers, allow_redirects=True)
req.encoding = 'utf-8'
print(req.headers['Content-Disposition']) # this code prints the text has encoding error
Also you can view my issue on github python requests https://github.com/psf/requests/issues/5463 )
urlso we can try it out?