Skip to content

Commit

Permalink
[Flat viewer] More feedback on unexpected response
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed May 5, 2017
1 parent 44a104d commit 891dc57
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 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.1.10'
VERSION = '2.1.11'

#dirs for services shipped with CLAM itself
CONFIGDIR = os.path.abspath(os.path.dirname(__file__) + '/../config/')
Expand Down
6 changes: 3 additions & 3 deletions clam/common/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ def view(self, file, **kwargs):
#filename will contain a random component to prevent clashes
filename = os.path.basename(file.filename).replace('.folia.xml','').replace('.xml','') + str("%034x" % random.getrandbits(128)) + '.folia.xml'
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 following it, and return it ourselves as our redirect
if 'Location' in r.headers:
#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] == '/':
url = self.url[:-1] + r.headers['Location']
else:
url = self.url + r.headers['Location']
return flask.redirect(url)
else:
return "Invalid response from FLAT"
return "Unexpected response from FLAT (HTTP " + str(r.status_code) + "): " + 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.1.10", #also change in clam.common.data.VERSION
version = "2.1.11", #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 891dc57

Please sign in to comment.