From 9a4ed4f37bb2e76658a83a2480e47a7c9f31e554 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 18 Jun 2015 11:25:30 -0400 Subject: [PATCH] LP#1409055 Python gateway HTTP protocol options * Default to https * Add support for modifying the default protocol * Add support for modifying request-specific protocol Signed-off-by: Bill Erickson --- src/python/osrf/gateway.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python/osrf/gateway.py b/src/python/osrf/gateway.py index eda1139..33f90d3 100644 --- a/src/python/osrf/gateway.py +++ b/src/python/osrf/gateway.py @@ -8,12 +8,18 @@ import urllib, urllib2, sys, re defaultHost = None class GatewayRequest: + + ''' package-wide default protocol ''' + default_protocol = 'https' + def __init__(self, service, method, params=[]): self.service = service self.method = method self.params = params self.path = 'gateway' self.bytes_read = 0 # for now this, this is really characters read + # request-specific protocol + self.proto = GatewayRequest.default_protocol def setPath(self, path): self.path = path @@ -50,7 +56,7 @@ class GatewayRequest: setDefaultHost = staticmethod(setDefaultHost) def buildURL(self): - return 'http://%s/%s' % (defaultHost, self.path) + return '%s://%s/%s' % (self.proto, defaultHost, self.path) class JSONGatewayRequest(GatewayRequest): def __init__(self, service, method, *params): -- 2.11.0