[issue17214] http.client.HTTPConnection.putrequest encode error

Christian Heimes report at bugs.python.org
Fri Jul 19 11:23:28 CEST 2013


Christian Heimes added the comment:

Something else is going on here. A valid server never returns an URL with non-ASCII chars. Your test server does the right thing, too:

$ LC_ALL=C wget http://www.libon.it/libon/search/isbn/3499155443
--2013-07-19 11:01:54--  http://www.libon.it/libon/search/isbn/3499155443
Resolving www.libon.it (www.libon.it)... 83.103.59.131
Connecting to www.libon.it (www.libon.it)|83.103.59.131|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://www.libon.it/ricerca/7818684/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-K%C3%A4fer/order/date_desc [following]
Incomplete or invalid multibyte sequence encountered
--2013-07-19 11:01:54--  http://www.libon.it/ricerca/7818684/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-K%C3%A4fer/order/date_desc
Reusing existing connection to www.libon.it:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

I have digged through the code. Now I think that I know what's going on here. The header parsing code unquotes and converts the Location header. The code in the 302 handler doesn't compensate and therefore fails.

Here is a patch that corrects the code in the 302 function.

----------
keywords: +patch
Added file: http://bugs.python.org/file30976/issue17214.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17214>
_______________________________________


More information about the Python-bugs-list mailing list