Skip to content

Commit

Permalink
Merge pull request #78 from robotpony/asserts-and-CORS-fix
Browse files Browse the repository at this point in the history
Asserts and cors fix
  • Loading branch information
adam-patterson committed Sep 3, 2013
2 parents a6e90d5 + 1a91184 commit 06b1e25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 06b1e25

Please sign in to comment.