Author: chabotc
Date: Wed Dec 10 11:21:17 2008
New Revision: 725391

URL: http://svn.apache.org/viewvc?rev=725391&view=rev
Log:
Make ApiServlet inherit from httpservlet (adds etags / expires tags, was 
disabled for debugging), and if debug = false, also add proper 
application/{type} content type headers for json, xml and atom (content types 
make debugging from your browser a nightmare hence the switch)

Modified:
    incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php
    incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php

Modified: incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php?rev=725391&r1=725390&r2=725391&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php (original)
+++ incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php Wed Dec 10 
11:21:17 2008
@@ -54,7 +54,7 @@
 /**
  * Common base class for API servlets.
  */
-abstract class ApiServlet {
+abstract class ApiServlet extends HttpServlet {
   protected $handlers = array();
   
   protected static $DEFAULT_ENCODING = "UTF-8";
@@ -65,6 +65,7 @@
   public static $MESSAGE_ROUTE = "messages";
 
   public function __construct() {
+    parent::__construct();
     $this->handlers[self::$PEOPLE_ROUTE] = new PersonHandler();
     $this->handlers[self::$ACTIVITY_ROUTE] = new ActivityHandler();
     $this->handlers[self::$APPDATA_ROUTE] = new AppDataHandler();

Modified: incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php?rev=725391&r1=725390&r2=725391&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php 
(original)
+++ incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php Wed 
Dec 10 11:21:17 2008
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -135,10 +136,13 @@
     $outputFormat = strtolower(trim(! empty($_POST[self::$FORMAT_PARAM]) ? 
$_POST[self::$FORMAT_PARAM] : (! empty($_GET[self::$FORMAT_PARAM]) ? 
$_GET[self::$FORMAT_PARAM] : 'json')));
     switch ($outputFormat) {
       case 'xml':
+        if (Config::get('debug')) $this->setContentType('application/xml');
         return new OutputXmlConverter();
       case 'atom':
+        if (Config::get('debug')) 
$this->setContentType('application/atom+xml');
         return new OutputAtomConverter();
       case 'json':
+        if (Config::get('debug')) $this->setContentType('application/json');
         return new OutputJsonConverter();
       default:
         // if no output format is set, see if we can match an input format 
header
@@ -146,11 +150,14 @@
         if (isset($_SERVER['CONTENT_TYPE'])) {
           switch ($_SERVER['CONTENT_TYPE']) {
             case 'application/atom+xml':
+              if (Config::get('debug')) 
$this->setContentType('application/atom+xml');
               return new OutputAtomConverter();
             case 'application/xml':
+              if (Config::get('debug')) 
$this->setContentType('application/xml');
               return new OutputXmlConverter();
             default:
             case 'application/json':
+              if (Config::get('debug')) 
$this->setContentType('application/json');
               return new OutputJsonConverter();
           }
         }


Reply via email to