From: Dan Scott Date: Thu, 18 Jun 2015 15:52:00 +0000 (-0400) Subject: LP#1409055 Support specific protocols for OpenSRF gateway requests X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flp1409055-python-https-via-dbs;p=working%2FOpenSRF.git LP#1409055 Support specific protocols for OpenSRF gateway requests If the user passes in a gateway hostname that contains a specific HTTP or HTTPS protocol, let's just use that. Signed-off-by: Dan Scott Signed-off-by: Bill Erickson --- diff --git a/src/python/osrf/gateway.py b/src/python/osrf/gateway.py index eda1139..8796ce2 100644 --- a/src/python/osrf/gateway.py +++ b/src/python/osrf/gateway.py @@ -50,6 +50,18 @@ class GatewayRequest: setDefaultHost = staticmethod(setDefaultHost) def buildURL(self): + """ + Builds the URL for the OpenSRF gateway based on the host and path + + Previous versions of the code assumed that the host would be a bare + hostname or IP address, and prepended the http:// protocol. However, + to enable more secure communications, now we check for the existence + of the HTTP or HTTPS prefix and use that if it has been supplied. + """ + + if defaultHost.lower().startswith(('http://', 'https://')): + return '%s/%s' % (defaultHost, self.path) + return 'http://%s/%s' % (defaultHost, self.path) class JSONGatewayRequest(GatewayRequest):