problem with http post

Amit Mongia mongiaamit at yahoo.com
Wed Apr 3 02:42:02 EST 2002


See i have a small problem. I am posting some parameters to a
particular url. Say i am posting to
www.karlulbrich.com/address/accept/. The parameter to be passed is say
myaddress. If i post the address then the link will work. If i dont
then it will return "Invalid number of arguements". So the following
code works for me.

encdata = 'myaddress=addressvalue1'
f =  urllib.urlopen("http://www.karlulbrich.com/address/accept/",
encdata)
print f.info()
print f.read()

But the following code gives me an "Invalid number of arguements"
error.

encdata = 'myaddress=addressvalue1'
conn = httplib.HTTP("karlulbrich.com")
conn.putrequest("POST", "/address/accept/")
conn.putheader('Content-type', 'application/x-www-form-urlencoded')
conn.putheader('Accept', 'text/plain') 
conn.endheaders()
conn.send(encdata)
reply, msg, hdrs = conn.getreply()
print(reply)
print(conn.getfile().read())

The reply variable tells me that the call is successfull and i am
reaching the server but the return value indicates invalid number of
arguements. This means that the server is not receiving myaddress.

Can anyone please tell me what the possible error can be. I am using
Python. 2.1.2. The error is not with urlencoding for sure as i have
tried that too.

Finally i also need to know how to upload files over https. Thats the
final aim.

Regards,
Amit Mongia.



More information about the Python-list mailing list