commit 28a91a48010f556e81bf62606e882ee3de7f9ca5
parent f79b822d96f9a0273d0e589b393642c157bcbf48
Author: Jan Dankert <devnull@localhost>
Date: Tue, 6 Nov 2012 23:19:11 +0100
Bei JSON- oder XML-Antworten auch die HTTP-Fehlermeldung im gewünschten Format liefern.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/util/Http.class.php b/util/Http.class.php
@@ -479,20 +479,20 @@ class Http
$types = Http::getAccept();
- if ( sizeof($types)==1 && in_array('application/json',$types) )
+ if ( $_REQUEST['output']=='json' || sizeof($types)==1 && in_array('application/json',$types) )
{
header('Content-Type: application/json');
require_once( OR_SERVICECLASSES_DIR."JSON.class.".PHP_EXT );
$json = new JSON();
- echo $json->encode( array('status'=>$status,'error'=>$text,'description'=>$message) );
+ echo $json->encode( array('status'=>$status,'error'=>$text,'description'=>$message,'reason'=>$reason) );
}
- elseif ( sizeof($types)==1 && in_array('application/xml',$types) )
+ elseif ( $_REQUEST['output']=='xml' || sizeof($types)==1 && in_array('application/xml',$types) )
{
header('Content-Type: application/xml');
require_once( OR_SERVICECLASSES_DIR."XML.class.".PHP_EXT );
$xml = new XML();
$xml->root='error';
- echo $xml->encode( array('status'=>$status,'error'=>$text,'description'=>$message) );
+ echo $xml->encode( array('status'=>$status,'error'=>$text,'description'=>$message,'reason'=>$reason) );
}
else
{