471,343 Members | 1,199 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

httplib.HTTPSConnection problem


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"
body =
'''Desc=&Bank=National&email=&creditcardholdername =fgfgg&creditcardtype=VISA&creditcardnumber=455701 3000314262&ReturnHTTP=%2A&SendeMail=No&UID=0407151 706104&MultiBank=No&FinalPrice=35.00&MerchantID=36 &CompanyName=Bizar+Software&Mode=Test&Platform=Pla inText&__Click=0&ABN=ABN+xx+xxx+xxx+xxx&Returnemai l=&creditcardexpiryyear=2004&CVV=&Name=fgfgg&reade rs=MEL0036&creditcardexpirymonth=7&Principal='''

h = httplib.HTTPSConnection("merchant.ematters.com.au" , 443)
h.request('POST', path, body)
resp = h.getresponse()
f = resp.fp
resp = resp.read()
print resp

With python 2.1, the server accepts the request correctly and has a
proper response:

<br>&response_text=GATEWAY BLOCKED=end

However, with python 2.3 I get:

<BODY TEXT="000000">
<H1>Error 500</H1>HTTP Web Server: Invalid POST Request Exception</BODY>

The debuglevel printouts show that python2.1 sends the request and
headers one at a time, where as python 2.3 sends the request and all the
headers at once, although the actual data send is identical, so I don't
see this as the problem. I actually hacked httplib in my python 2.3
installion to get _output() to send immediately rather than buffer, so
that the debug output is identical to the python2.1 output, and that
gives me a different error:

<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY><H1>Error 400</H1>Invalid
request -- HOST header was not sent</BODY></HTML>

So I am suspicious that the debug output is not showing what is actually
sent? I am really tearing my hair out with this problem because I really
need this app to work with pyton 2.3.3, and I cannot see what else it is
doing differently to cause this problem.

Are there any httplib/socket/ssl gurus out there that have any suggestions?

Jul 18 '05 #1
0 2323

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by scummer | last post: by
1 post views Thread by Brian Beck | last post: by
4 posts views Thread by Marc Poulhiès | last post: by
reply views Thread by Robert | last post: by
4 posts views Thread by michaelparkin | last post: by
reply views Thread by philip20060308 | last post: by
reply views Thread by gcn | last post: by
5 posts views Thread by runningwild | last post: by
4 posts views Thread by Patrick Altman | last post: by
reply views Thread by rosydwin | last post: by

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.