From 7b31a7889dee790b6150d939894f1a299e8bbb15 Mon Sep 17 00:00:00 2001 From: Adam Patterson Date: Wed, 28 Aug 2013 11:38:29 -0700 Subject: [PATCH 1/3] Testing this locally shows that the HTTP_ORIGIN header is expected to not be set if the call is not a CORS call. This should be fine ... just do nothing. --- lib/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.php b/lib/api.php index 19023e0..b160f96 100644 --- a/lib/api.php +++ b/lib/api.php @@ -53,9 +53,9 @@ public function restrictTo($types) { */ public function crossOrigin() { - + if (empty($_SERVER['HTTP_ORIGIN'])) - throw new Exception("'HTTP_ORIGIN' unknown. Failed to set required 'Access-Control-Allow-Origin' header for CORS handshake.", 500); + return; // This is not a CORS request $this->add_header('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']); $this->add_header('Access-Control-Allow-Credentials', 'true'); From 8121e4ec1c2c73d799d70e705ee6247074139aea Mon Sep 17 00:00:00 2001 From: Adam Patterson Date: Wed, 28 Aug 2013 11:43:47 -0700 Subject: [PATCH 2/3] Turn assertion warnings on if the debug flag is set. --- lib/_config.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/_config.php b/lib/_config.php index 5d63b1d..cbf9a2d 100644 --- a/lib/_config.php +++ b/lib/_config.php @@ -51,6 +51,10 @@ public static function errorHandlerCallback($code, $string, $file, $line, $conte // Set up PHP error handling (note these settings are overriden by explicit PHP ini settigns, we should address this) assert_options(ASSERT_WARNING, 0); +if (PRESTO_DEBUG) { + assert_options(ASSERT_ACTIVE, 1); + assert_options(ASSERT_WARNING, 1); +} ini_set('html_errors', false); error_reporting(E_ALL); set_error_handler(array("PrestoException", "errorHandlerCallback"), E_ALL); From 1a911842d5d8c36e43fec72a07bee701878139fb Mon Sep 17 00:00:00 2001 From: Adam Patterson Date: Wed, 28 Aug 2013 11:56:03 -0700 Subject: [PATCH 3/3] Turning PRESTO_DEBUG on. It seems to me this should be on for development, but I will check with @ngallagher before merging. --- lib/_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_config.php b/lib/_config.php index cbf9a2d..d839edd 100644 --- a/lib/_config.php +++ b/lib/_config.php @@ -4,7 +4,7 @@ define('PRESTO', 'presto.php'); define('PRESTO_VERSION', 'presto-v1.11'); -define('PRESTO_DEBUG', 0); +define('PRESTO_DEBUG', 1); define('PRESTO_TRACE', 1); define('PRESTO_TRACE_KEY', '_presto_trace'); define('VERSION_HEADER', 'X-Api-Version');