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:ga*****@geochemsource.com
web: http://designasign.biz