aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Copeland <ben.copeland@linaro.org>2017-08-09 13:44:21 +0100
committerAndy Doan <andy.doan@linaro.org>2017-08-10 14:27:34 +0000
commitd62ccea708851c60fe1abf4cb06175bdfd1e2973 (patch)
tree2c6880df6d1037bc806d05632531c12f54170cd7
parentfaf89bfbfde91a82fa19d4ca48b24235f16dc38f (diff)
downloadlinaro-license-protection-d62ccea708851c60fe1abf4cb06175bdfd1e2973.tar.gz
S3: Match S3 protocol with LLP protocol
This fixes CTT-459, and allows S3 to generate us http download links for insecure connections Change-Id: Id0be5a70f154e02f8b7473d16e2e8e633333ec69 Reviewed-on: https://review.linaro.org/20896 Reviewed-by: Andy Doan <andy.doan@linaro.org>
-rw-r--r--license_protected_downloads/artifact/base.py2
-rw-r--r--license_protected_downloads/artifact/local.py2
-rw-r--r--license_protected_downloads/artifact/s3.py5
-rw-r--r--license_protected_downloads/views.py3
4 files changed, 7 insertions, 5 deletions
diff --git a/license_protected_downloads/artifact/base.py b/license_protected_downloads/artifact/base.py
index 7536e14..2041635 100644
--- a/license_protected_downloads/artifact/base.py
+++ b/license_protected_downloads/artifact/base.py
@@ -98,7 +98,7 @@ class Artifact(object):
def get_eulas(self):
raise NotImplementedError()
- def get_file_download_response(self, method='GET'):
+ def get_file_download_response(self, method='GET', force_http=False):
raise NotImplementedError()
def get_textile_files(self):
diff --git a/license_protected_downloads/artifact/local.py b/license_protected_downloads/artifact/local.py
index d6fdc6b..7e5b04b 100644
--- a/license_protected_downloads/artifact/local.py
+++ b/license_protected_downloads/artifact/local.py
@@ -41,7 +41,7 @@ class LocalArtifact(Artifact):
mtype = 'text'
return mtype
- def get_file_download_response(self, method='GET'):
+ def get_file_download_response(self, method='GET', force_http=False):
"Return HttpResponse which will send path to user's browser."
assert not self.isdir()
file_name = os.path.basename(self.full_path)
diff --git a/license_protected_downloads/artifact/s3.py b/license_protected_downloads/artifact/s3.py
index 6bd870b..df342dc 100644
--- a/license_protected_downloads/artifact/s3.py
+++ b/license_protected_downloads/artifact/s3.py
@@ -79,10 +79,11 @@ class S3Artifact(Artifact):
return 'text'
return self.mtype
- def get_file_download_response(self, method='GET'):
+ def get_file_download_response(self, method='GET', force_http=False):
"Return HttpResponse which will send path to user's browser."
assert not self.isdir()
- return HttpResponseRedirect(self.item.generate_url(90, method=method))
+ return HttpResponseRedirect(
+ self.item.generate_url(90, method=method, force_http=force_http))
@cached_prop
def build_info_buffer(self):
diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py
index 67aa090..982b155 100644
--- a/license_protected_downloads/views.py
+++ b/license_protected_downloads/views.py
@@ -243,7 +243,8 @@ def file_server_get(request, path):
if request.method == 'GET':
Download.mark(request, artifact)
- return artifact.get_file_download_response(request.method)
+ force_http = not request.is_secure()
+ return artifact.get_file_download_response(request.method, force_http)
def get_textile_files(request):