Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Implement 405 for unhandled non-GET requests. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion wptserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,13 @@ def handle_one_request(self):
time.sleep(latency / 1000.)

if handler is None:
response.set_error(404)
if request.method in ["GET"]:
# Assume no handler means path to a non-existing resource.
response.set_error(404, "Not found")
else:
# Using a non-GET method without a dedicated handler is
# considered not allowed. E.g. if requesting files via POST.
response.set_error(405, "Method not allowed")
else:
try:
handler(request, response)
Expand Down