summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/wsgi/httputil.py
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-03-27 06:24:56 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-03-27 06:24:56 +0000
commitd64a280c20229e374684e9b5e392fdf878ed5514 (patch)
treebd0edee43d0f6569824a3d3d38960a5602c58da8 /sca-cpp/trunk/modules/wsgi/httputil.py
parentdac887d0f494151b210588ce694c55ce27f07263 (diff)
Add scripts to setup HTTPS support. A few fixes to get HTTPS working end to end with both HTTPD and WSGI servers. Minor cleanup of the HTTPD config scripts.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@928160 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/wsgi/httputil.py')
-rw-r--r--sca-cpp/trunk/modules/wsgi/httputil.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/sca-cpp/trunk/modules/wsgi/httputil.py b/sca-cpp/trunk/modules/wsgi/httputil.py
index e5f26db143..92da7ec09c 100644
--- a/sca-cpp/trunk/modules/wsgi/httputil.py
+++ b/sca-cpp/trunk/modules/wsgi/httputil.py
@@ -18,9 +18,10 @@
# HTTP client proxy functions
-from httplib import HTTPConnection
+from httplib import HTTPConnection, HTTPSConnection
from urlparse import urlparse
from StringIO import StringIO
+import os.path
from util import *
from atomutil import *
from jsonutil import *
@@ -37,9 +38,20 @@ class client:
req = StringIO()
writeStrings(jsonRequest(id, func, args), req)
id = id + 1
- c = HTTPConnection(self.uri.hostname, 80 if self.uri.port == None else self.uri.port)
+ print "HTTP connect:", self.uri.hostname
+ c = None
+ if self.uri.scheme == "https":
+ if os.path.exists("server.key"):
+ c = HTTPSConnection(self.uri.hostname, 443 if self.uri.port == None else self.uri.port, "server.key", "server.crt")
+ else:
+ c = HTTPSConnection(self.uri.hostname, 443 if self.uri.port == None else self.uri.port)
+ else:
+ c = HTTPConnection(self.uri.hostname, 80 if self.uri.port == None else self.uri.port)
+ print "HTTP connection:", c
c.request("POST", self.uri.path, req.getvalue(), {"Content-type": "application/json-rpc"})
res = c.getresponse()
+ print "HTTP response:", res
+ print "HTTP status:", res.status
if res.status != 200:
return None
return jsonResultValue((res.read(),))