It would be nice to be able to have a user-defined fallback (i.e. variable_get/set). This was possible in 7.x-3.3 and earlier before the major architectural changes, but ServicesContentTypeNegotiator class is in charge of this now. In order to change this I would need to rewrite rest_server or hack services.

ServicesContentTypeNegotiator::getResponseFormatContentTypeNegotiations()

diff --git a/servers/rest_server/includes/ServicesContentTypeNegotiator.inc b/servers/rest_server/includes/ServicesContentTypeNegotiator.inc
index cc7ec27..4b2f1fb 100644
--- a/servers/rest_server/includes/ServicesContentTypeNegotiator.inc
+++ b/servers/rest_server/includes/ServicesContentTypeNegotiator.inc
@@ -84,7 +84,7 @@ class ServicesContentTypeNegotiator implements ServicesContentTypeNegotiatorInte
     }
 
     // Get the best matching format, default to json
-    $response_format = 'json';
+    $response_format = variable_get('rest_server_default_response_format', 'json');
     $http_accept = $context->getServerVariable('HTTP_ACCEPT');
     if (!empty($http_accept)) {
       $mime = $this->mimeParse();

I will post a patch shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mradcliffe’s picture

Status: Active » Needs review
FileSize
1.15 KB

This changes the default string to a variable_get and adds a hook_uninstall() implementation to rest_server to clean up.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community

looks good

ygerasimov’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Also added some documentation about introduced variable.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.