Example #1
0
 /**
  * Make request
  *
  * @param  array $globals The $_SERVER super-global
  * @return \Psr\Http\Message\ServerRequestInterface
  */
 public function makeRequest(array $globals) : ServerRequestInterface
 {
     $method = $globals['REQUEST_METHOD'];
     $uri = $this->makeUri($globals);
     $headers = $this->makeHeaders($globals);
     $cookies = Cookies::parseHeader($headers->get('Cookie', []));
     $body = $this->makeBody();
     $files = [];
     // TODO: Create factory method for uploaded files
     $request = new Request($method, $uri, $headers, $cookies, $globals, $body, $files);
     if ($method === 'POST' && in_array($request->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'])) {
         // parsed body must be $_POST
         $request = $request->withParsedBody($_POST);
     }
     return $request;
 }
Example #2
0
 /**
  * [getMediaType description]
  *
  * @return [type] [description]
  */
 public function getMediaType()
 {
     if ($ext = $this->getExtension()) {
         if (isset($this->mediaTypeExtensions[$ext])) {
             return $this->mediaTypeExtensions[$ext];
         }
     }
     return parent::getMediaType();
 }