Commit 22a9581f authored by Jonathan Hunt's avatar Jonathan Hunt

#53 Try avoiding sending two Vary headers.

parent 1fe9b872
......@@ -346,6 +346,8 @@ function climbnz_api_services_resources() {
*/
function climbnz_api_node_view($node, $view_mode, $langcode) {
if (($node->type == 'place' || $node->type =='route') && $view_mode == 'full') {
if (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== FALSE ||
strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== FALSE) {
drupal_add_http_header('Vary', 'Accept', TRUE);
}
......@@ -353,14 +355,14 @@ function climbnz_api_node_view($node, $view_mode, $langcode) {
if ($node->type == 'place' && $view_mode == 'full') {
// Return via services, force path to be Place node.
drupal_add_http_header('Vary', 'Accept', TRUE);
//drupal_add_http_header('Vary', 'Accept', TRUE);
$_GET['q'] = 'api/place/' . $node->nid;
$endpoint_name = 'climbnz_api1';
return services_endpoint_callback($endpoint_name);
}
if ($node->type == 'route' && $view_mode == 'full') {
// Return via services, force path to be Route node.
drupal_add_http_header('Vary', 'Accept', TRUE);
//drupal_add_http_header('Vary', 'Accept', TRUE);
$_GET['q'] = 'api/route/' . $node->nid;
$endpoint_name = 'climbnz_api1';
return services_endpoint_callback($endpoint_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment