Esempio n. 1
0
 public function testRegister()
 {
     $xml = Mad_Controller_Mime_Type::lookupByExtension("iphone");
     $this->assertNull($xml);
     Mad_Controller_Mime_Type::register('text/iphone', 'apl', array('text/phone'), array('aap'));
     $iphone = Mad_Controller_Mime_Type::lookup("text/iphone");
     $this->assertNotNull($iphone);
     $iphone = Mad_Controller_Mime_Type::lookupByExtension("apl");
     $this->assertNotNull($iphone);
 }
Esempio n. 2
0
 /**
  * Set the content type for this mock request.
  *
  * $contentType may be a type ("application/xml"), an
  * extension ("xml"), a Mad_Controller_Mime_Type, or NULL.
  *
  *   $request->setContentType('application/xml');  // type  
  *   $request->setContentType('xml')               // extension
  *
  * If you want to manipulate the content type header directly,
  * you need to call this method with NULL after setting the header
  * to wipe any previously cached value.  See getContentType().
  *
  *   $request->setServer('CONTENT_TYPE', 'raw header value');
  *   $request->setContentType(null);
  *
  * @param  mixed $contentType
  * @return void
  */
 public function setContentType($contentType)
 {
     if (is_string($contentType)) {
         if (strpos($contentType, '/') !== false) {
             $contentType = Mad_Controller_Mime_Type::lookup($contentType);
         } else {
             $contentType = Mad_Controller_Mime_Type::lookupByExtension($contentType);
         }
     }
     $this->_contentType = $contentType;
 }
Esempio n. 3
0
 /**
  * @todo implement getContentTypeWithParameters() et al.
  */
 public function getContentType()
 {
     if (!isset($this->_contentType)) {
         $type = $this->getServer('CONTENT_TYPE');
         // strip parameters from content-type like "; charset=UTF-8"
         if (is_string($type)) {
             if (preg_match('/^([^,\\;]*)/', $type, $matches)) {
                 $type = $matches[1];
             }
         }
         $this->_contentType = Mad_Controller_Mime_Type::lookup($type);
     }
     return $this->_contentType;
 }