[issue11898] Sending binary data with a POST request in httplib can cause Unicode exceptions

2011-06-10 Thread Ion Scerbatiuc

Ion Scerbatiuc  added the comment:

Hello,

I would like to subscribe to the issue. The problem seems to indeed exist in 
Python 2.7. 

What I'm doing is to proxy HTTP requests (using Django) and the PUT / POST 
requests are working fine on Python 2.6 but are failing on 2.7 with the error 
already presented in the first bero's message.

I'm using httplib2 and the code looks like

{{
http = httplib2.Http(timeout=5)
try:
resp, content = http.request(
request_url, method,
body=body, headers=headers)
except (AttributeError, httplib.ResponseNotReady), e:
# ...
}}

Body is the result of the Django's request.read() which in fact contain the 
binary data from the PUT / POST request.

The full stack trace is:
{{
Traceback:
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/django/core/handlers/base.py"
 in get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File "/home/cyrus/workspace/macleod/apps/macleod/macleod/auth.py" in 
_decorated_view
  33. return view(request, *args, **kwargs)
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/django/views/decorators/csrf.py"
 in wrapped_view
  39. resp = view_func(*args, **kwargs)
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/django/views/decorators/csrf.py"
 in wrapped_view
  52. return view_func(*args, **kwargs)
File "/home/cyrus/workspace/macleod/apps/macleod/macleod/views.py" in dispatch
  55. original=request.build_absolute_uri())
File "/home/cyrus/workspace/macleod/apps/macleod/macleod/handlers/its.py" in 
proxy
  51. body=body, headers=headers)
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/httplib2/__init__.py"
 in request
  1129. (response, content) = self._request(conn, 
authority, uri, request_uri, method, body, headers, redirections, cachekey)
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/httplib2/__init__.py"
 in _request
  901. (response, content) = self._conn_request(conn, request_uri, 
method, body, headers)
File 
"/home/cyrus/workspace/macleod/ve/lib/python2.7/site-packages/httplib2/__init__.py"
 in _conn_request
  862. conn.request(method, request_uri, body, headers)
File "/usr/local/lib/python2.7/httplib.py" in request
  941. self._send_request(method, url, body, headers)
File "/usr/local/lib/python2.7/httplib.py" in _send_request
  975. self.endheaders(body)
File "/usr/local/lib/python2.7/httplib.py" in endheaders
  937. self._send_output(message_body)
File "/usr/local/lib/python2.7/httplib.py" in _send_output
  795. msg += message_body
}}

--
nosy: +cyrus

___
Python tracker 
<http://bugs.python.org/issue11898>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11898] Sending binary data with a POST request in httplib can cause Unicode exceptions

2011-06-10 Thread Ion Scerbatiuc

Ion Scerbatiuc  added the comment:

Hello again,

After some digging I found that the "real" problem was because the provided URL 
was a unicode string and the concatenation was failing. Maybe this is not a big 
deal, but I think we should least do a proper assertion for the provided URL or 
some other checks, because the error encountered is at least confusing.

--

___
Python tracker 
<http://bugs.python.org/issue11898>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com