Skip to content

Commit

Permalink
attempted fix for FLAT redirection problem
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Nov 22, 2017
1 parent 117e809 commit c3238f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import clam.common.util
import clam.common.viewers

VERSION = '2.2.1'
VERSION = '2.2.2'

#dirs for services shipped with CLAM itself
CONFIGDIR = os.path.abspath(os.path.dirname(__file__) + '/../config/')
Expand Down
6 changes: 4 additions & 2 deletions clam/common/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@ def view(self, file, **kwargs):
r = requests.post(self.url + '/pub/upload/', allow_redirects=False, files=[('file',(filename,file,'application/xml'))], data={'configuration':self.configuration,'mode':self.mode})
#FLAT redirects after upload, we catch the redirect rather than following it automatically, and return it ourselves as our redirect
if r.status_code == 302 and 'Location' in r.headers:
if self.url and self.url[-1] == '/' and r.headers['Location'][0] == '/':
if r.headers['Location'][:4].lower() == 'http': #location is an absolute URL
url = r.headers['Location']
elif self.url and self.url[-1] == '/' and r.headers['Location'][0] == '/':
url = self.url[:-1] + r.headers['Location']
else:
url = self.url + r.headers['Location']
return flask.redirect(url)
else:
return "Unexpected response from FLAT (HTTP " + str(r.status_code) + "): " + r.text
return "Unexpected response from FLAT (HTTP " + str(r.status_code) + ", target was " + self.url + "): " + r.text

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def read(fname):

setup(
name = "CLAM",
version = "2.2.1", #also change in clam.common.data.VERSION
version = "2.2.2", #also change in clam.common.data.VERSION
author = "Maarten van Gompel",
author_email = "proycon@anaproy.nl",
description = ("Turns command-line NLP tools into fully-fledged RESTful webservices with an auto-generated web-interface for human end-users."),
Expand Down

0 comments on commit c3238f0

Please sign in to comment.