Example #1
0
 public function testSetVarsWithOnlyRaw()
 {
     $_GET = [];
     $_POST = [];
     $_REQUEST = [];
     $_COOKIE = [];
     $_SESSION = [];
     $_SERVER = ['HTTP_METHOD' => 'POST', 'CONTENT_TYPE' => 'application/json'];
     $o = new RawHttpRequest();
     $this->assertEmpty($o->getVars());
     $value = ['test' => uniqid('test:'), 'brrr' => 123];
     $o->setRawVars($value);
     $this->assertNotEmpty($o->getVars());
     $this->assertEquals($value, $o->getVars());
 }
Example #2
0
 /**
  * @param HttpRequestA $oRequest
  * @return \vsc\domain\models\ModelA
  * @throws \vsc\presentation\responses\ExceptionResponseError
  */
 public function handleRequest(HttpRequestA $oRequest)
 {
     if (!$oRequest->isGet() && !RawHttpRequest::isValid($oRequest)) {
         $oRequest = new RawHttpRequest();
         vsc::getEnv()->setHttpRequest($oRequest);
     }
     switch ($oRequest->getHttpMethod()) {
         case HttpRequestTypes::GET:
             $oModel = $this->handleGet($oRequest);
             break;
         case HttpRequestTypes::HEAD:
             $oModel = $this->handleHead($oRequest);
             break;
         case HttpRequestTypes::POST:
             $oModel = $this->handlePost($oRequest);
             break;
         case HttpRequestTypes::PUT:
             $oModel = $this->handlePut($oRequest);
             break;
         case HttpRequestTypes::DELETE:
             $oModel = $this->handleDelete($oRequest);
             break;
         default:
             throw new ExceptionResponseError('Method [' . $oRequest->getHttpMethod() . '] is unavailable.', HttpResponseType::METHOD_NOT_ALLOWED);
     }
     return $oModel;
 }
Example #3
0
 /**
  * @param \vsc\presentation\requests\HttpRequestA $oRequest
  */
 public function __construct($oRequest = null)
 {
     /* @var RawHttpRequest $oRequest */
     if (!RawHttpRequest::isValid($oRequest)) {
         $oRequest = new RawHttpRequest();
         vsc::getEnv()->setHttpRequest($oRequest);
     }
     $this->id = $oRequest->getVar('id');
     $this->method = $oRequest->getVar('method');
     $this->params = $oRequest->getVar('params');
 }
Example #4
0
 public function testBasic__construct()
 {
     $_SERVER = ['HTTP_METHOD' => 'POST', 'CONTENT_TYPE' => 'application/json'];
     $o = new RawHttpRequest();
     $this->assertEmpty($o->getRawVars());
 }
Example #5
0
 public function __construct($rawInput)
 {
     $this->raw = $rawInput;
     parent::__construct();
 }
Example #6
0
 public function constructRawVars($sRawInput = null)
 {
     parent::constructRawVars($sRawInput);
 }