From a8d1541e34709b6595b4dd4aaa48dd1ba46594eb Mon Sep 17 00:00:00 2001 From: Yi Hsiao Date: Wed, 14 Mar 2018 09:48:30 -0400 Subject: [PATCH] remove proxy app --- i5k/settings.py | 1 - i5k/urls.py | 2 -- proxy/__init__.py | 1 - proxy/models.py | 0 proxy/tests.py | 9 --------- proxy/urls.py | 6 ------ proxy/views.py | 44 -------------------------------------------- 7 files changed, 63 deletions(-) delete mode 100644 proxy/__init__.py delete mode 100644 proxy/models.py delete mode 100644 proxy/tests.py delete mode 100644 proxy/urls.py delete mode 100644 proxy/views.py diff --git a/i5k/settings.py b/i5k/settings.py index 20948cf4f..e00c08691 100755 --- a/i5k/settings.py +++ b/i5k/settings.py @@ -159,7 +159,6 @@ 'social.apps.django_app.default', 'captcha', 'dashboard', - 'proxy', 'hmmer', 'clustal', ) diff --git a/i5k/urls.py b/i5k/urls.py index 873c51681..ee5f87784 100644 --- a/i5k/urls.py +++ b/i5k/urls.py @@ -22,8 +22,6 @@ # Uncomment the admin/doc line below to enable admin documentation: url(r'^admin/doc/', include('django.contrib.admindocs.urls'), name='doc'), url(r'^captcha/', include('captcha.urls')), - url(r'^proxy/', include('proxy.urls', namespace='proxy')), - # user authentication url(r'^set_institution$', 'app.views.set_institution', name='set_institution'), url(r'^info_change$', 'app.views.info_change', name='info_change'), diff --git a/proxy/__init__.py b/proxy/__init__.py deleted file mode 100644 index a6221b3de..000000000 --- a/proxy/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '1.0.2' diff --git a/proxy/models.py b/proxy/models.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/proxy/tests.py b/proxy/tests.py deleted file mode 100644 index 20366f331..000000000 --- a/proxy/tests.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.test import TestCase -from django.core.urlresolvers import reverse - -class Proxy_viewTest(TestCase): - def test_url_and_args(self): - response = self.client.get('/proxy/http://golr.berkeleybop.org/select?defType=edismax&qt=standard&indent=on&wt=json&rows=10&start=0&fl=*,score&facet=true&facet.mincount=1&facet.sort=count&json.nl=arrarr&facet.limit=25&fq=document_category:%22ontology_class%22&fq=source:(biological_process%20OR%20molecular_function%20OR%20cellular_component)&facet.field=annotation_class&facet.field=synonym&facet.field=alternate_id&q=go:&qf=annotation_class%5E5&qf=annotation_class_label_searchable%5E5&qf=synonym_searchable%5E1&qf=alternate_id%5E1&json.wrf=jQuery171018561481428332627_1420660818198&_=1420660827771') - #response = self.client.get('/proxy/http://tw.yahoo.com') - print response.content - self.assertEquals(response.status_code, 200) diff --git a/proxy/urls.py b/proxy/urls.py deleted file mode 100644 index 21c2b0c00..000000000 --- a/proxy/urls.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.conf.urls import url -from .views import proxy_view - -urlpatterns = [ - url(r'^(?P.*)$', proxy_view, name='proxy_view'), -] diff --git a/proxy/views.py b/proxy/views.py deleted file mode 100644 index 6a9845df9..000000000 --- a/proxy/views.py +++ /dev/null @@ -1,44 +0,0 @@ -import requests -from django.http import HttpResponse, HttpResponseRedirect - -def proxy_view(request, url, requests_args=None): - if request.method == 'GET': - if not 'http://' in url: - url = url.replace('http:/', 'http://') - if not 'https://' in url: - url = url.replace('https:/', 'https://') - for safe_url in ['//golr.berkeleybop.org', '//a2-proxy1.stanford.edu:8080/solr/', '//golr.geneontology.org/solr']: - if safe_url in url: - param = request.GET.urlencode() - response = requests.get(url + '?' + param) - proxy_response = HttpResponse( - response.content, - status=response.status_code) - excluded_headers = set([ - # Hop-by-hop headers - # ------------------ - # Certain response headers should NOT be just tunneled through. These - # are they. For more info, see: - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1 - 'connection', 'keep-alive', 'proxy-authenticate', - 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', - 'upgrade', - - # Although content-encoding is not listed among the hop-by-hop headers, - # it can cause trouble as well. Just let the server set the value as - # it should be. - 'content-encoding', - - # Since the remote server may or may not have sent the content in the - # same encoding as Django will, let Django worry about what the length - # should be. - 'content-length', - ]) - for key, value in response.headers.iteritems(): - if key.lower() in excluded_headers: - continue - proxy_response[key] = value - return proxy_response - return HttpResponseRedirect('https://i5k.nal.usda.gov') - else: - return HttpResponse('Not Supported')