I experienced problems with xmlrpc services, which never gave back a result due to following configuration:
The server is a drupal 6 installation with services module and i18n module installed and language negotiation set to Path prefix with language fallback. Resulting in a http status code of 301 to an URL like http://mysite.com/en/services/xmlrpc
My requesting site is a drupal 5 installation.
The server gave back the results to drupal 5, but with http code 301 instead of 200 - submitting 200 as redirect code. This can be seen in function _xmlrpc in /includes/xmlrpc.inc of both drupal 5 and 6.
And in both versions any $result->code different to 200 results as an xmlrpc_error and returns FALSE - in this case without any errormessage.
For sure, I could write the URL to request directly with the path_prefix into the requiring function / module. But this doesn't seem as the drupal way to do things - as normaly drupal URL's do work with i18n, independant from the language settings. I feel like, the services module should alter the return value of the http status code when i18n is installed - but I couldn't figure how to do that. Has anybody an advise for me, how it could be guaranteed that the returning http status code is 200 instead of 301?
Thanks for any help
anschinsan
In case of any other user experiencing the same issue: For the moment I altered the _xmlrpc function (yes, it's an ugly core hack):
<?php
$result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml);
if (($result->code == '301') && ($result->redirect_code == '200')) $result->code = '200';
if ($result->code != 200) {
xmlrpc_error($result->code, $result->error);
return FALSE;
}
//INSTEAD OF
$result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml);
if ($result->code != 200) {
xmlrpc_error($result->code, $result->error);
return FALSE;
}
?>
Comments
Comment #1
kylebrowning commented