Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

API: Return a 404 error when no director rule is matched

  • Loading branch information...
commit 1fc780ce2b36b159f5296a73f6581cd1a79424f9 1 parent 1dda9ae
@ajshort ajshort authored
Showing with 7 additions and 0 deletions.
  1. +3 −0  control/Director.php
  2. +4 −0 tests/control/DirectorTest.php
View
3  control/Director.php
@@ -331,6 +331,9 @@ protected static function handleRequest(SS_HTTPRequest $request, Session $sessio
}
}
}
+
+ // No URL rules matched, so return a 404 error.
+ return new SS_HTTPResponse('No URL rule was matched', 404);
}
/**
View
4 tests/control/DirectorTest.php
@@ -281,6 +281,10 @@ public function testExtractRequestHeaders() {
$this->assertEquals($headers, Director::extract_request_headers($request));
}
+ public function testUnmatchedRequestReturns404() {
+ $this->assertEquals(404, Director::test('no-route')->getStatusCode());
+ }
+
}
class DirectorTestRequest_Controller extends Controller implements TestOnly {
Please sign in to comment.
Something went wrong with that request. Please try again.