[Sungrazr-svn] [114] Sungrazr_Server_Adapter_JsonRpc: [CHG] throw a fault when the incoming JSON request cannot be decoded.

0 views
Skip to first unread message

cl...@killersoft.com

unread,
Feb 25, 2008, 4:34:43 PM2/25/08
to Sungra...@googlegroups.com
Revision
114
Author
clay
Date
2008-02-25 13:34:42 -0800 (Mon, 25 Feb 2008)

Log Message

Sungrazr_Server_Adapter_JsonRpc: [CHG] throw a fault when the incoming JSON request cannot be decoded.

Modified Paths

Diff

Modified: trunk/Sungrazr/Server/Adapter/JsonRpc.php (113 => 114)


--- trunk/Sungrazr/Server/Adapter/JsonRpc.php	2008-02-10 19:55:19 UTC (rev 113)
+++ trunk/Sungrazr/Server/Adapter/JsonRpc.php	2008-02-25 21:34:42 UTC (rev 114)
@@ -31,7 +31,7 @@
      * @var array
      * 
      */
-    protected $_Sungrazr_Server_Adapter = array(
+    protected $_Sungrazr_Server_Adapter_JsonRpc = array(
         'return'            => false,
         'headers'           => array(),
         'content_types' => array(
@@ -306,6 +306,13 @@
         $properties = array('method', 'params', 'id');
         $obj = json_decode($serialized);
         
+        if (! is_object($obj)) {
+            return $this->fault(
+                'The request was not a valid JSON object; It could not be parsed.',
+                -1
+            );            
+        }
+        
         foreach ($properties as $p) {
             if (! empty($obj->{$p})) {
                 $this->{$p} = $obj->{$p};
Reply all
Reply to author
Forward
0 new messages