httplib question

L

Laszlo Zsolt Nagy

Hello,

This is from the docs, from section 11.6.1 (HTTPConnection Objects)

HTTPConnection instances have the following methods:
request( method, url[, body[, headers]])
[.....]
The headers argument should be a mapping of extra HTTP headers to send with the request.


AFAIK the only standard mapping type is the dictionary type.
I'm trying to do this:
import httplib
AGENT_MSIE = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)"
HOST = "www.google.com"
URL = "http://"+HOST+"/"
headers = {}
headers["User-Agent"] = AGENT_MSIE
conn = httplib.HTTPConnection(HOST)
conn.request("HEAD", URL, headers)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\lib\httplib.py", line 718, in request
self._send_request(method, url, body, headers)
File "C:\Python23\lib\httplib.py", line 742, in _send_request
self.send(body)
File "C:\Python23\lib\httplib.py", line 576, in send
self.sock.sendall(str)
File "<string>", line 1, in sendall
TypeError: sendall() argument 1 must be string or read-only buffer, not dict

What should I pass instead of a dict?


--
Best regards,
Laszlo

mailto:[email protected]
web: http://designasign.biz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top