1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

PR review changes

This commit is contained in:
Matej Bačo 2022-04-05 16:57:22 +00:00
parent 45e9040fa5
commit 4110709874
3 changed files with 5 additions and 5 deletions

View file

@ -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,
],

View file

@ -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());

View file

@ -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';