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:
[color=blue][color=green][color=darkred]
>>> 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.HTTPCon nection(HOST)
>>> conn.request("H EAD", URL, headers)[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\li b\httplib.py", line 718, in request
self._send_requ est(method, url, body, headers)
File "C:\Python23\li b\httplib.py", line 742, in _send_request
self.send(body)
File "C:\Python23\li b\httplib.py", line 576, in send
self.sock.senda ll(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:gandalf@ geochemsource.c om
web: http://designasign.biz
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:
[color=blue][color=green][color=darkred]
>>> 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.HTTPCon nection(HOST)
>>> conn.request("H EAD", URL, headers)[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\li b\httplib.py", line 718, in request
self._send_requ est(method, url, body, headers)
File "C:\Python23\li b\httplib.py", line 742, in _send_request
self.send(body)
File "C:\Python23\li b\httplib.py", line 576, in send
self.sock.senda ll(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:gandalf@ geochemsource.c om
web: http://designasign.biz