Browse code

Adding option signurl_use_https for signurl to use https prefix

Julien Recurt authored on 2017/09/06 20:20:48
Showing 2 changed files
... ...
@@ -148,6 +148,7 @@ class Config(object):
148 148
     # Disabled by default because can create a latency with a CONTINUE status reply
149 149
     # expected for every send file requests.
150 150
     use_http_expect = False
151
+    signurl_use_https = False
151 152
 
152 153
     ## Creating a singleton
153 154
     def __new__(self, configfile = None, access_key=None, secret_key=None, access_token=None):
... ...
@@ -143,6 +143,9 @@ def sign_url_base_v2(**parms):
143 143
     parms['access_key']=Config.Config().access_key
144 144
     parms['host_base']=Config.Config().host_base
145 145
     parms['object'] = s3_quote(parms['object'], quote_backslashes=False, unicode_output=True)
146
+    parms['proto'] = 'http'
147
+    if Config.Config().signurl_use_https:
148
+        parms['proto'] = 'https'
146 149
     debug("Expiry interpreted as epoch time %s", parms['expiry'])
147 150
     signtext = 'GET\n\n\n%(expiry)d\n/%(bucket)s/%(object)s' % parms
148 151
     param_separator = '?'
... ...
@@ -155,7 +158,7 @@ def sign_url_base_v2(**parms):
155 155
     debug("Signing plaintext: %r", signtext)
156 156
     parms['sig'] = s3_quote(sign_string_v2(encode_to_s3(signtext)), unicode_output=True)
157 157
     debug("Urlencoded signature: %s", parms['sig'])
158
-    url = "http://%(bucket)s.%(host_base)s/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms
158
+    url = "%(proto)s://%(bucket)s.%(host_base)s/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms
159 159
     if content_disposition is not None:
160 160
         url += "&response-content-disposition=" + s3_quote(content_disposition, unicode_output=True)
161 161
     if content_type is not None: