masperro / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Cannot POST content from a generator #180

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
import httlib2
import poster
fields = { 'file' : open('somefile', 'rb') }
body, headers = poster.encode.multipart_encode(fields)                          

content = httplib2.Http().request(url, method="POST", headers=headers, 
body=body)    

What is the expected output? What do you see instead?
 File "/home/kgk/work/bisquik/bisque05/bqcore/bq/util/http/http_client.py", line 101, in request
    client = client,)
  File "/home/kgk/work/bisquik/bisque05/bqcore/bq/util/http/sync_request.py", line 68, in request
    return client.request(uri, method, body, headers, **kw)
  File "/home/kgk/work/bisquik/bisque05/bqenv/lib/python2.6/site-packages/httplib2-0.7.1-py2.6.egg/httplib2/__init__.py", line 1436, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/kgk/work/bisquik/bisque05/bqenv/lib/python2.6/site-packages/httplib2-0.7.1-py2.6.egg/httplib2/__init__.py", line 1188, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/kgk/work/bisquik/bisque05/bqenv/lib/python2.6/site-packages/httplib2-0.7.1-py2.6.egg/httplib2/__init__.py", line 1124, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "/usr/lib/python2.6/httplib.py", line 914, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.6/httplib.py", line 954, in _send_request
    self.send(body)
  File "/usr/lib/python2.6/httplib.py", line 759, in send
    self.sock.sendall(str)
  File "<string>", line 1, in sendall
TypeError: sendall() argument 1 must be string or buffer, not generator

What version of the product are you using? On what operating system?

httlib2-0.7.1
Please provide any additional information below.

Original issue reported on code.google.com by kkvilek...@gmail.com on 29 Sep 2011 at 5:18