473,787 Members | 2,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.HTTPSCo nnection.debugl evel = 1
connection = httplib.HTTPSCo nnection(host_n ame, key_file = key,
cert_file = cert)
connection.putr equest("POST", path)
connection.puth eader("Content-Length", str(len(body)))

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

connection.endh eaders()
connection.send (body)

response = connection.getr esponse()
connection.clos e()

(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 3712
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.getr esponse()
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***********@g mail.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.HTTPSCo nnection.debugl evel = 1
connection = httplib.HTTPSCo nnection(host_n ame, key_file = key,
cert_file = cert)
connection.putr equest("POST", path)
connection.puth eader("Content-Length", str(len(body)))

...(some more headers)...

connection.endh eaders()
connection.send (body)

response = connection.getr esponse()
connection.clos e()

(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***********@g mail.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.HTTPSCo nnection.debugl evel = 1
connection = httplib.HTTPSCo nnection(host_n ame, key_file = key,
cert_file = cert)
connection.putr equest("POST", path)
connection.puth eader("Content-Length", str(len(body)))

...(some more headers)...

connection.endh eaders()
connection.send (body)

response = connection.getr esponse()
connection.clos e()

(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)

iD8DBQBC1Yh5HJd udm4KnO0RAn32AK DhuPqPLTUh8Cz3v RNtcMRZDfHSUgCe MzfU
zfNiyFIHDcosx5a NLAWLuNM=
=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
1390
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", self.url) h.putheader("Host", self.host)
2
2179
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. It seems because httplib (based on socket.py) try to autenticate on the proxy. I'm only with this problem ? it's impossible :-|
2
15937
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 look at the class below, when req == 'getFreeBusyInfo' all functions perfectly, but when req == 'conflictRequest' I run into problems of the nature "400 Bad Request". As you will notice, I also tried the shorter HTTPConnection instance method...
0
2454
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 in python 2.3.3 compiled with openssl-0.9.7d. The script below demonstrates the problem. ============================================ import httplib path = "/cmaonline.nsf/ePayForm?OpenForm"
1
2882
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
2935
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
5
6821
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.
6
2408
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 2.5.0's httplib (via urllib/urllib2), Perl's LWP::UserAgent 2.033 and Firefox 2.0. Only Python sends the request in such a way that the mailserver closes the connection before I get any data from the POST request (immediate FIN packet after the POST...
4
2321
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...
0
9655
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
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.