473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

httplib question

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.HTTPCon nection(HOST)
conn.request("H EAD", URL, headers)

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

Jul 18 '05 #1
0 1470

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2381
by: Adrian Albisser | last post by:
Hey to everybody, im just beginning to program in python. So i was trying some function but always when i try the range function i get a error message. for number in range(1,100): print number Error---> There's an error in your program: expected an indented block
3
15432
by: alastair | last post by:
Hi, I'm attempting to test out some functionality of the Apache http server. What I'd like to do is send a file to the server - eg. a text file or binary file (I will be testing gzipped transfers eventually ....). At the moment I can test out sending a set of parameters to the server, and using mod_python, I have a python script which displays these values.
1
2875
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and traceback at the end of this post. The odd thing is, using DEPRECATED FUNCTIONS to perform the same function works fine!
0
2922
by: Robert | last post by:
did you solve this problem? It seems to be still present here with py2.3.5. Robert -- From: Manish Jethani <manish.j@gmx.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en
4
3699
by: michaelparkin | last post by:
Hi, Sorry to post what might seem like a trivial problem here, but its driving me mad! I have a simple https client that uses httplib to post data to a web server. When I post over http & https using curl the data is recieved by the web server with no problems.
5
19803
by: scott | last post by:
Hello, From a shell script, I have used /usr/bin/curl to access a web site and pass a cookie (as required by the site). But, I can't seem to accomplish this task with Python. I would like to use the httplib module to do this. Any thoughts on this subject? I would like to hard code the cookie in the code so it works every time: i.e. cookie = 'auth=buster%3A12345678901234567890exZ9rzMqgtxa5A'.
5
6799
by: runningwild | last post by:
Helo, This is the first time I have cared about httplib's HTTPSConnection. In the docs I read "Note: HTTPS support is only available if the socket module was compiled with SSL support." Although my small test script "seems" to work when connecting to a webserver via HTTPS I am really not sure.
4
2309
by: Patrick Altman | last post by:
I am attempting to use a HEAD request against Amazon S3 to check whether a file exists or not and if it does parse the md5 hash from the ETag in the response to verify the contents of the file so as to save on bandwidth of uploading files when it is not necessary. If the file exist, the HEAD works as expected and I get valid headers back that I can parse and pull the ETag out of the dictionary using getheader('ETag') (using the slice to...
3
4068
by: rhXX | last post by:
hi all, i'm using this tutorial example import httplib h = httplib.HTTP("www.python.org") h.putrequest('GET','/index.html') h.putheader('User-Agent','Lame Tutorial Code') h.putheader('Accept','text/html')
0
8067
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6015
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1336
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.