From 41107098745260b62a3d6229a5ce5b5c0ff0575f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Apr 2022 16:57:22 +0000 Subject: [PATCH] PR review changes --- app/config/errors.php | 6 +++--- app/controllers/general.php | 2 +- src/Appwrite/Extend/Exception.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index ca305ed0b..6ebc31179 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -78,9 +78,9 @@ return [ 'description' => 'An internal server error occurred.', 'code' => 500, ], - Exception::GENERAL_FORCED_HTTPS_IGNORED => [ - 'name' => Exception::GENERAL_FORCED_HTTPS_IGNORED, - 'description' => 'Appwrite instance forces secure communication. Switch to HTTPS protocol in your endpoint.', + Exception::GENERAL_METHOD_UNSUPPORTED => [ + 'name' => Exception::GENERAL_METHOD_UNSUPPORTED, + 'description' => 'The HTTP method is unsupported by the current protocol or resource.', 'code' => 500, ], diff --git a/app/controllers/general.php b/app/controllers/general.php index 4cf77bb4b..30e2d4cd9 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -174,7 +174,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS if ($request->getProtocol() !== 'https') { if($request->getMethod() !== Request::METHOD_GET) { - throw new Exception('HTTPS communication required.', 500, Exception::GENERAL_FORCED_HTTPS_IGNORED); + throw new Exception('Method unsupported over HTTP.', 405, Exception::GENERAL_METHOD_UNSUPPORTED); } return $response->redirect('https://'.$request->getHostname().$request->getURI()); diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index a5858d662..04b44b57b 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -46,7 +46,7 @@ class Exception extends \Exception const GENERAL_ROUTE_NOT_FOUND = 'general_route_not_found'; const GENERAL_CURSOR_NOT_FOUND = 'general_cursor_not_found'; const GENERAL_SERVER_ERROR = 'general_server_error'; - const GENERAL_FORCED_HTTPS_IGNORED = 'general_forced_https_ignored'; + const GENERAL_METHOD_UNSUPPORTED = 'general_method_unsupported'; /** Users */ const USER_COUNT_EXCEEDED = 'user_count_exceeded';