diff --git a/onionshare/web/send_base_mode.py b/onionshare/web/send_base_mode.py index 86d34016..fe7e57f8 100644 --- a/onionshare/web/send_base_mode.py +++ b/onionshare/web/send_base_mode.py @@ -162,15 +162,17 @@ class SendBaseModeWeb: # Tell GUI the individual file started history_id = self.cur_history_id 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.REQUEST_INDIVIDUAL_FILE_STARTED, path, {"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(): chunk_size = 102400 # 100kb diff --git a/onionshare/web/web.py b/onionshare/web/web.py index b5b805ec..de2d71b5 100644 --- a/onionshare/web/web.py +++ b/onionshare/web/web.py @@ -266,7 +266,14 @@ class Web: ) 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( render_template("405.html", static_url_path=self.static_url_path), 405 )