aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-09-04 17:22:33 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-09-04 17:22:33 -0700
commitd17dbe2591868bf2834c5f2ecef502b03a698d8d (patch)
tree79e99ca5c1f188e376b299cbaa3a6d0d000e62a7 /engine
parent4d47ecbb311d556f155ad866bbce358fbfb51218 (diff)
parenta6846beb2f74aa38215b09a6a6dc18b912446bba (diff)
downloadelgg-d17dbe2591868bf2834c5f2ecef502b03a698d8d.tar.gz
elgg-d17dbe2591868bf2834c5f2ecef502b03a698d8d.tar.bz2
Merge pull request #59 from surevine/ticket3709
Fixes #3709 Detecting if client can accept application/json in ajax forward action hook to avoid download prompts on older browsers.
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/actions.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 4ccffd267..99e22e104 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -446,7 +446,17 @@ function ajax_forward_hook($hook, $type, $reason, $params) {
$params['status'] = -1;
}
- header("Content-type: application/json");
+ // Check the requester can accept JSON responses, if not fall back to
+ // returning JSON in a plain-text response. Some libraries request
+ // JSON in an invisible iframe which they then read from the iframe,
+ // however some browsers will not accept the JSON MIME type.
+ if (stripos($_SERVER['HTTP_ACCEPT'], 'application/json') === FALSE) {
+ header("Content-type: text/plain");
+ }
+ else {
+ header("Content-type: application/json");
+ }
+
echo json_encode($params);
exit;
}