mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Merge pull request #1056 from mig5/error_405_early
Communicate a 405 error properly to the UI
This commit is contained in:
commit
e9f91a9bcf
@ -162,15 +162,17 @@ class SendBaseModeWeb:
|
|||||||
# Tell GUI the individual file started
|
# Tell GUI the individual file started
|
||||||
history_id = self.cur_history_id
|
history_id = self.cur_history_id
|
||||||
self.cur_history_id += 1
|
self.cur_history_id += 1
|
||||||
|
|
||||||
|
# Only GET requests are allowed, any other method should fail
|
||||||
|
if request.method != "GET":
|
||||||
|
return self.web.error405(history_id)
|
||||||
|
|
||||||
self.web.add_request(
|
self.web.add_request(
|
||||||
self.web.REQUEST_INDIVIDUAL_FILE_STARTED,
|
self.web.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||||
path,
|
path,
|
||||||
{"id": history_id, "filesize": filesize},
|
{"id": history_id, "filesize": filesize},
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only GET requests are allowed, any other method should fail
|
|
||||||
if request.method != "GET":
|
|
||||||
return self.web.error405()
|
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
chunk_size = 102400 # 100kb
|
chunk_size = 102400 # 100kb
|
||||||
|
@ -266,7 +266,14 @@ class Web:
|
|||||||
)
|
)
|
||||||
return self.add_security_headers(r)
|
return self.add_security_headers(r)
|
||||||
|
|
||||||
def error405(self):
|
def error405(self, history_id):
|
||||||
|
self.add_request(
|
||||||
|
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||||
|
"{}".format(request.path),
|
||||||
|
{"id": history_id, "status_code": 405},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.add_request(Web.REQUEST_OTHER, request.path)
|
||||||
r = make_response(
|
r = make_response(
|
||||||
render_template("405.html", static_url_path=self.static_url_path), 405
|
render_template("405.html", static_url_path=self.static_url_path), 405
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user