Example #1
0
 public function __construct()
 {
     $this->scheme = 'http';
     if (ArrayHelper::value($_SERVER, 'HTTPS', 'Off') == 'on') {
         $this->scheme .= 's';
     }
     $port = (int) ArrayHelper::value($_SERVER, 'SERVER_PORT', 80);
     if (!in_array($port, [80, 443])) {
         $this->port = $port;
     }
     $this->query = ArrayHelper::value($_SERVER, 'QUERY_STRING');
     $this->path = ArrayHelper::value($_SERVER, 'PATH_INFO');
     list($this->host, ) = explode(':', ArrayHelper::value($_SERVER, 'HTTP_HOST'), 2);
 }
Example #2
0
 public function __construct()
 {
     $this->body = new PhpInputStream();
     $this->method = ArrayHelper::value($_SERVER, 'REQUEST_METHOD', RequestMethod::GET);
     $protocol = ArrayHelper::value($_SERVER, 'SERVER_PROTOCOL');
     $this->protocol = stristr($protocol, '1.1') ? '1.1' : '1.0';
     foreach (getallheaders() as $header => $value) {
         $this->addHeader($header, $value);
     }
     $this->query = $_GET;
     $this->cookies = $_COOKIE;
     if (!empty($_POST)) {
         $this->parsedBody = $_POST;
     } else {
         $this->parsedBody = $this->getBody();
     }
     if (!empty($_FILES)) {
         foreach ($_FILES as $file => $data) {
             $this->files[$file] = new UploadedFile($data['tmp_name'], $data['size'], $data['error'], $data['name'], $data['type']);
         }
     }
     $this->uri = new GlobalsUri();
 }
Example #3
0
 public function getPost($key, $default = null)
 {
     if (is_array($this->parsedBody)) {
         return ArrayHelper::value($this->parsedBody, $key, $default);
     }
     return $default;
 }