Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     $this->setNoCache(true);
     if (isset($_SERVER['CONTENT_TYPE']) && strtolower($_SERVER['CONTENT_TYPE']) != $_SERVER['CONTENT_TYPE']) {
         // 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']);
     }
     $acceptedContentTypes = array('application/atom+xml', 'application/xml', 'application/json', 'application/json-rpc', 'application/jsonrequest', 'application/javascript');
     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)) {
             $prefix = substr($_SERVER['CONTENT_TYPE'], 0, strpos($_SERVER['CONTENT_TYPE'], '/'));
             $acceptedMediaPrefixes = array('image', 'video', 'audio');
             if (!in_array($prefix, $acceptedMediaPrefixes)) {
                 throw new Exception("When posting to the social end-point you have to specify a content type,\n              supported content types are: 'application/json', 'application/xml' and 'application/atom+xml'.\n              For content upload, content type can be 'image/*', 'audio/*' and 'video/*'");
             }
         }
     }
 }
Esempio n. 2
0
 public function __construct()
 {
     parent::__construct();
     $this->setNoCache(true);
     $this->handlers[self::$PEOPLE_ROUTE] = new PersonHandler();
     $this->handlers[self::$ACTIVITY_ROUTE] = new ActivityHandler();
     $this->handlers[self::$APPDATA_ROUTE] = new AppDataHandler();
     $this->handlers[self::$MESSAGE_ROUTE] = new MessagesHandler();
 }
Esempio n. 3
0
 public function __construct()
 {
     parent::__construct();
     $handlers = Config::get('handlers');
     if (empty($handlers)) {
         $this->handlers[] = new OpenSocialDataHandler();
         $this->handlers[] = new StateFileDataHandler();
     } else {
         $handlers = explode(',', $handlers);
         foreach ($handlers as $handler) {
             $this->handlers[] = new $handler();
         }
     }
 }
 /**
  * Tests HttpServlet->setNoCache()
  */
 public function testSetNoCache()
 {
     $this->HttpServlet->setNoCache(!$this->noCache);
     $this->assertNotEquals($this->noCache, $this->HttpServlet->getNoCache());
 }