You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ch...@apache.org on 2009/04/09 11:24:32 UTC

svn commit: r763576 - /incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php

Author: chabotc
Date: Thu Apr  9 09:24:32 2009
New Revision: 763576

URL: http://svn.apache.org/viewvc?rev=763576&view=rev
Log:
Fix an warning when E_ALL is set on non-post's without a content-type set

Modified:
    incubator/shindig/trunk/php/src/social/servlet/ApiServlet.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=763576&r1=763575&r2=763576&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php (original)
+++ incubator/shindig/trunk/php/src/social/servlet/ApiServlet.php Thu Apr  9 09:24:32 2009
@@ -77,18 +77,20 @@
       // make sure the content type is in all lower case since that's what we'll check for in the handlers
       $_SERVER['CONTENT_TYPE'] = strtolower($_SERVER['CONTENT_TYPE']);
     }
-    // normalize things like "application/json; charset=utf-8" to application/json
     $acceptedContentTypes = array('application/atom+xml', 'application/xml', 'application/json');
-    foreach ($acceptedContentTypes as $contentType) {
-      if (strpos($_SERVER['CONTENT_TYPE'], $contentType) !== false) {
-        $_SERVER['CONTENT_TYPE'] = $contentType;
-        $this->setContentType($contentType);
-        break;
+    if (isset($_SERVER['CONTENT_TYPE'])) {
+      // normalize things like "application/json; charset=utf-8" to application/json
+      foreach ($acceptedContentTypes as $contentType) {
+        if (strpos($_SERVER['CONTENT_TYPE'], $contentType) !== false) {
+          $_SERVER['CONTENT_TYPE'] = $contentType;
+          $this->setContentType($contentType);
+          break;
+        }
       }
     }
     if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
       if (! isset($_SERVER['CONTENT_TYPE']) || ! in_array($_SERVER['CONTENT_TYPE'], $acceptedContentTypes)) {
-        throw new Exception("[{$_SERVER['CONTENT_TYPE']}] When posting to the social end-point you *must* specify a content type, supported content types are: 'application/json', 'application/xml' and 'application/atom+xml'");
+        throw new Exception("When posting to the social end-point you have to specify a content type, supported content types are: 'application/json', 'application/xml' and 'application/atom+xml'");
       }
     }
   }