473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

httplib/HTTPS Post Problem

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.

When I post using my python client the headers get there, but the body
of the message does not.

My code is pretty standard and has the format:
httplib.HTTPSConnection.debuglevel = 1
connection = httplib.HTTPSConnection(host_name, key_file = key,
cert_file = cert)
connection.putrequest("POST", path)
connection.putheader("Content-Length", str(len(body)))

....(some more headers)...

connection.endheaders()
connection.send(body)

response = connection.getresponse()
connection.close()

(some code has been removed for clarity)..

I can see in the debug messages the body getting sent, but nothing
arrives at
the server...

I think I would understand whats going on better if I knew how Python
uses the
underlying socket - does it

a) open the socket, send the header & body together or
b) send the header, wait, then send the body?

I think the answer to this question solve my problem - can anyone help?

Thanks.

p.s. I'm using Python 2.3.3 [GCC 3.3.3 (SuseLinx)]

Jul 21 '05 #1
4 3686
Am Mon, 11 Jul 2005 06:29:23 -0700 schrieb michaelparkin:
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.

When I post using my python client the headers get there, but the body
of the message does not.


Hi,

can you look at the access log of the server? A slash at the
end of a URL is important (www.google.com/ is different from
www.google.com)

response = connection.getresponse()
What does "print response" do?

You can listen on the wire with ethereal (Capture, then "follow tcp-stream")

HTH,
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
Jul 21 '05 #2
Have you tried using pycurl? That may be an easier way to port over your CURL
code directly. Relatively easy to use, too.

-Pete

mi***********@gmail.com wrote:
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.

When I post using my python client the headers get there, but the body
of the message does not.

My code is pretty standard and has the format:
httplib.HTTPSConnection.debuglevel = 1
connection = httplib.HTTPSConnection(host_name, key_file = key,
cert_file = cert)
connection.putrequest("POST", path)
connection.putheader("Content-Length", str(len(body)))

...(some more headers)...

connection.endheaders()
connection.send(body)

response = connection.getresponse()
connection.close()

(some code has been removed for clarity)..

I can see in the debug messages the body getting sent, but nothing
arrives at
the server...

I think I would understand whats going on better if I knew how Python
uses the
underlying socket - does it

a) open the socket, send the header & body together or
b) send the header, wait, then send the body?

I think the answer to this question solve my problem - can anyone help?

Thanks.

p.s. I'm using Python 2.3.3 [GCC 3.3.3 (SuseLinx)]


Jul 21 '05 #3
Am Montag, den 11.07.2005, 06:29 -0700 schrieb mi***********@gmail.com:
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.
Just a curious guess: Are you behind a proxy? If so, it's a known and
never fixed bug from Python 1.5 times ;)

You might also try to use PyCurl.

Andreas

When I post using my python client the headers get there, but the body
of the message does not.

My code is pretty standard and has the format:


httplib.HTTPSConnection.debuglevel = 1
connection = httplib.HTTPSConnection(host_name, key_file = key,
cert_file = cert)
connection.putrequest("POST", path)
connection.putheader("Content-Length", str(len(body)))

...(some more headers)...

connection.endheaders()
connection.send(body)

response = connection.getresponse()
connection.close()

(some code has been removed for clarity)..

I can see in the debug messages the body getting sent, but nothing
arrives at
the server...

I think I would understand whats going on better if I knew how Python
uses the
underlying socket - does it

a) open the socket, send the header & body together or
b) send the header, wait, then send the body?

I think the answer to this question solve my problem - can anyone help?

Thanks.

p.s. I'm using Python 2.3.3 [GCC 3.3.3 (SuseLinx)]


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBC1Yh5HJdudm4KnO0RAn32AKDhuPqPLTUh8Cz3vRNtcM RZDfHSUgCeMzfU
zfNiyFIHDcosx5aNLAWLuNM=
=aJGI
-----END PGP SIGNATURE-----

Jul 21 '05 #4
Thanks for the replies, Andreas and Peter.

Andreas Kostyrka wrote:

<snip>
Just a curious guess: Are you behind a proxy? If so, it's a known and
never fixed bug from Python 1.5 times ;)
No, I'm not behind a proxy - the server is on the same PC as my client
(while I'm testing!).
You might also try to use PyCurl.


I've quickly read about PyCurl, but it only seems to allow HTTP HEAD,
GET, POST and PUT methods - though please correct me if I'm wrong.

I'd like to use httpLib in Python as I also need the DELETE method and
the possibility of adding some extra headers and extra methods (I'm
working on something like this : http://sw.nokia.com/uriqa/URIQA.html
that allows MGET, MPUT, MPOST, etc.).

I've done some more testing and still can't work out why Python
operates differently to other http clients... any ideas?

Thanks,

Michael.

<snip>

Jul 22 '05 #5

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

Similar topics

0
by: Joseph | last post by:
Hello All, I am using email to create a multipart message that I need to post to a url. I have been doing it semi-manually with httplib: h = httplib.HTTP(self.host) h.putrequest("POST",...
2
by: Glauco | last post by:
I'm using a library based on httplib. Recently i've done a conversion for use of https with a key and certificate file. This goes perfectly :-) . Now, the problem is passing throw an http_proxy....
2
by: scummer | last post by:
Hi, I am having a problem with the httplib HTTPConnection object. While I can easily send requests that don't have any payload (ie. "get"), I encounter issues if I want to post xml data. If you...
0
by: Terry Kerr | last post by:
Hi, I have an app that makes a https POST to a remote server that I have no control over. The app runs fine in python 2.1.3 with socket.ssl compiled with openssl-0.9.6, however it will not run...
1
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...
0
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;...
5
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." ...
6
by: Haakon Riiser | last post by:
After a long debugging session while scripting my webmail, I believe I have traced the problem to the way httplib sends POST requests. I have compared tcpdump listings from Python 2.4.3 and...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.