--- json_server.module	2010-03-01 14:05:27.000000000 -0600
+++ json_server_new.module	2010-03-01 14:06:20.000000000 -0600
@@ -149,14 +149,26 @@ function json_server_encode_json($conten
       return $contents;
     }
     
-    // Add encoding with gzip.
+// Add encoding with gzip.
     header('Content-Encoding: '. $encoding);
     $output = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
     $size = strlen($contents);
+    $crc = crc32($contents);
+
     $contents = gzcompress($contents, 9);
-    $contents = substr($contents, 0, $size);
+    $contents = substr($contents, 0, strlen($contents) - 4);
+
+    $contents .= _json_server_get_4_chars($crc);
+    $contents .= _json_server_get_4_chars($size);
 
     return $output . $contents;
   }
 }
 
+function _json_server_get_4_chars($val) {
+  for ($i = 0; $i < 4; $i ++) {
+    $chars .= chr($val % 256);
+    $val = floor($val / 256);
+  }
+  return $chars;
+}
