Exemple #1
0
 public function testRequestCanBeCastToAString()
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $request->setUri('/');
     $request->setContent('foo=bar&bar=baz');
     $this->assertEquals("GET / HTTP/1.1\r\n\r\nfoo=bar&bar=baz", $request->toString());
 }
 /**
  * Generates an Exception from a Invalid Post Request
  *
  * @param string $publicMessage
  * @param Http\Request $request
  * @return self
  */
 public static function fromInvalidRequest($publicMessage, Http\Request $request)
 {
     return new self(sprintf('Invalid Request received [%s]', $request->toString()), (string) $publicMessage);
 }
 /**
  * dispatch request
  * 
  * @param \Zend\Http\Request $request
  * @return Tinebase_Server_Interface|null
  */
 public static function getDispatchServer(\Zend\Http\Request $request)
 {
     // Test server conditions from server plugins
     foreach (self::_getServerPlugins() as $serverPlugin) {
         $server = call_user_func_array(array($serverPlugin, 'getServer'), array($request));
         if ($server instanceof Tinebase_Server_Interface) {
             Tinebase_Core::set('serverclassname', get_class($server));
             return $server;
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
         Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Request: " . $request->toString());
     }
     throw new Tinebase_Exception('No valid server found for request');
 }
/*
GET URI 1.1
HEADERS Content-Type: text/html
BODY -> Conteudo
*/
use Zend\Http\Request;
// Request GET
//$request = new Request();
//$request->setMethod(Request::METHOD_GET);
//$request->setUri("http://google.com");
//$request->setContent("Conteúdo da nossa request");
//
//echo $request->toString();
// POST
//$request = new Request();
//$request->setMethod(Request::METHOD_POST);
//$request->getPost()->set('nome','Wesley');
//$request->getPost()->set('x','10');
//$request->setUri("http://google.com");
//$request->setContent($request->getPost()->toString());
//
//echo $request->toString();
$request = new Request();
$request->setMethod(Request::METHOD_POST);
$request->getPost()->set('nome', 'Wesley');
$request->getHeaders()->addHeaders(array('headerX' => 10, 'headerY' => 20));
$request->getHeaders()->addHeaderLine('Content-Type: text/html');
$request->setUri("http://google.com");
$request->setContent($request->getPost()->toString());
echo $request->toString();