httplib/HTTPS Post Problem

2005-07-11 Thread 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.

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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: httplib/HTTPS Post Problem

2005-07-22 Thread michaelparkin
Thanks for the replies, Andreas and Peter.

Andreas Kostyrka wrote:



> 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.



-- 
http://mail.python.org/mailman/listinfo/python-list


HTTPSConnection & Password

2005-08-02 Thread michaelparkin
Hi,

I'm using httplib to create a mutually authenticated HTTPS connection
with a server.

I create the connection as follows:

c = httplib.HTTPSConnection(uri, key_file = key, cert_file = cert)

However, because I am using a private key I keep getting asked to enter
the password to open that key every time I run the script.

I've had a dig around and can't seem to find a way of specifying the
password so that the user can supply it on the command line, or so I
can script/fully automate these connections. The ideal scenario would
be to be able to specify the password on the command line like in
curl/pyCurl

How can I set the password for the private key so it doesn't keep
asking me for it?

Appologies if I've missed something obvious here.

Thanks,

Michael.

p.s. I need to use httplib (rather than pyCurl) as I need to be able to
specify methods other than GET and POST in my requests to the server.

-- 
http://mail.python.org/mailman/listinfo/python-list