예제 #1
0
 /**
  * @param array                           $serverParams  Server parameters, typically from $_SERVER
  * @param array                           $uploadedFiles Upload file information, a tree of UploadedFiles
  * @param string                          $uri           URI for the request, if any.
  * @param string                          $method        HTTP method for the request, if any.
  * @param string|resource|StreamInterface $body          Message body, if any.
  * @param array                           $headers       Headers for the message, if any.
  * @param array                           $cookies       Cookies for the message, if any.
  * @param array                           $queryParams   Query params for the message, if any.
  * @param array|object                    $parsedBody    The deserialized body parameters, if any.
  * @param string                          $protocol      HTTP protocol version.
  *
  * @throws InvalidArgumentException for any invalid value.
  */
 public function __construct(array $serverParams = [], array $uploadedFiles = [], $uri = null, string $method = null, $body = null, array $headers = [], array $cookies = [], array $queryParams = [], $parsedBody = null, string $protocolVersion = '1.1')
 {
     $this->validateUploadedFiles($uploadedFiles);
     $this->attributes = [];
     $this->serverParams = $serverParams;
     $this->uploadedFiles = $uploadedFiles;
     $this->cookieParams = $cookies;
     $this->queryParams = $queryParams;
     $this->parsedBody = $parsedBody;
     parent::__construct($method, $uri, $headers, $body, $protocolVersion);
 }
예제 #2
0
 public function __construct($method, $uri, array $headers = array(), $body = NULL, $protocolVersion = '1.1')
 {
     parent::__construct($method, $uri, $headers, $body, $protocolVersion);
     if (!in_array($this->getMethod(), array('HEAD', 'GET', 'POST'))) {
         throw new \InvalidArgumentException('Invalid or unsupported method ' . $this->getMethod());
     }
     if (!in_array($this->getUri()->getScheme(), array('http', 'https'))) {
         throw new \InvalidArgumentException('Invalid or unsupported scheme ' . $this->getUri()->getScheme());
     }
     if (!filter_var((string) $this->getUri(), FILTER_VALIDATE_URL)) {
         throw new \InvalidArgumentException('Invalid or unsupported URI ' . (string) $this->getUri());
     }
 }
예제 #3
0
 /**
  * @param null|string $method HTTP method for the request
  * @param null|string|UriInterface $uri URI for the request
  * @param array $headers Headers for the message
  * @param string|resource|StreamInterface $body Message body
  * @param string $protocolVersion HTTP protocol version
  * @param array $serverParams the value of $_SERVER superglobal
  *
  * @throws InvalidArgumentException for an invalid URI
  */
 public function __construct($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1', array $serverParams = [])
 {
     $this->serverParams = $serverParams;
     parent::__construct($method, $uri, $headers, $body, $protocolVersion);
 }
예제 #4
0
 public function __construct($uri, array $headers = [])
 {
     $method = 'GET';
     $headers += ['User-Agent' => static::$userAgent, 'Accept' => 'application/json'];
     parent::__construct($method, $uri, $headers);
 }
예제 #5
0
파일: Request.php 프로젝트: kix/apiranha
 /**
  * Request constructor.
  *
  * @param null|string $method
  * @param null|\Psr\Http\Message\UriInterface|string $uri
  * @param array $headers
  * @param null $body
  * @param string $protocolVersion
  */
 public function __construct($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1')
 {
     parent::__construct(self::$methodMap[$method], $uri, $headers, $body, $protocolVersion);
 }
예제 #6
0
 public function __construct($method, $uri, array $query = [], array $headers = [], $body = null, $protocolVersion = '1.1')
 {
     $this->query = $query;
     parent::__construct($method, $uri, [], null, $protocolVersion);
 }