Bonjour à tous,

/Ceci est mon premier post sur la liste GLPI, si j’enfreins une règle
quelconque, n'hésitez pas à me le signaler :)/

En voulant utiliser utiliser le client XMLRPC du Zend Framework
(v1.11.12) pour contacter GLPI v0.83.4 qui fait tourner le plugin
webservices v1.3.1, j'obtenais l'exception suivante :
> Fatal error: Uncaught exception 'Zend_XmlRpc_Client_HttpException'
> with message 'Bad content type' in
> /usr/share/php/ZendFramework-1.11.12-minimal/library/Zend/XmlRpc/Client.php:288
> Stack trace:
> #0
> /usr/share/php/ZendFramework-1.11.12-minimal/library/Zend/XmlRpc/Client.php(372):
> Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request))

Après analyse du code j'ai trouvé le code en cause : les lignes 73-76 du
fichier "webservices/xmlrpc.php" :
> if ($_SERVER["CONTENT_TYPE"] != "text/xml") {
> header("HTTP/1.0 500 Bad content type");
> die("Bad content type");
> }
Mon client "Zend_XmlRpc_Client" envoyant "Content-Type: text/xml;
charset=utf-8", le code de vérification voit donc autre chose que
"text/xml" et retourne une 500.

Je propose donc le correctif suivant :
> --- glpi-webservices-1.3.1/webservices/xmlrpc.php Fri Jun 29 06:43:28 2012
> +++ webservices-fixed/webservices/xmlrpc.php Mon Nov 12 15:46:10 2012
> @@ -70,7 +70,7 @@
>
> error_reporting(E_ALL);
>
> -if ($_SERVER["CONTENT_TYPE"] != "text/xml") {
> +if (!array_key_exists('CONTENT_TYPE', $_SERVER) ||
> strpos($_SERVER['CONTENT_TYPE'], 'text/xml') === false) {
> header("HTTP/1.0 500 Bad content type");
> die("Bad content type");
> }

Si quelqu'un ayant les droits suffisant sur la forge Redminepouvait me
rajouter comme Rapporteur pour le projet "webservices" je pourrais
poster tout cela là-bas (d'autant plus que j'ai aussi une évolution
-déjà implémentée- à proposer ;)).

-- 
DUVERGIER Claude

_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to