Skip to content

Commit

Permalink
FIX bad http-errors attached as 'output' header after bottle upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Jan 17, 2016
1 parent f2ee424 commit 031f7a4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pypiserver/_app.py
Expand Up @@ -96,7 +96,7 @@ def update():
try:
action = request.forms[':action']
except KeyError:
raise HTTPError(400, output=":action field not found")
raise HTTPError(400, ":action field not found")

if action in ("verify", "submit"):
return ""
Expand All @@ -105,13 +105,13 @@ def update():
try:
content = request.files['content']
except KeyError:
raise HTTPError(400, output="content file field not found")
raise HTTPError(400, "content file field not found")
zip_data = content.file.read()
try:
zf = zipfile.ZipFile(BytesIO(zip_data))
zf.getinfo('index.html')
except Exception:
raise HTTPError(400, output="not a zip file")
raise HTTPError(400, "not a zip file")
return ""

if action == "remove_pkg":
Expand All @@ -130,21 +130,21 @@ def update():
return ""

if action != "file_upload":
raise HTTPError(400, output="action not supported: %s" % action)
raise HTTPError(400, "action not supported: %s" % action)

try:
content = request.files['content']
except KeyError:
raise HTTPError(400, output="content file field not found")
raise HTTPError(400, "content file field not found")

if "/" in content.filename:
raise HTTPError(400, output="bad filename")
raise HTTPError(400, "bad filename")

if not config.overwrite and core.exists(packages.root, content.filename):
log.warn("Cannot upload package(%s) since it already exists! \n" +
" You may use `--overwrite` option when starting server to disable this check. ",
content.filename)
raise HTTPError(409, output="file already exists")
raise HTTPError(409, "file already exists")

core.store(packages.root, content.filename, content.save)
return ""
Expand Down

0 comments on commit 031f7a4

Please sign in to comment.