2017-03-19 02:30:36 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync\REST;
|
|
|
|
|
|
|
|
class Request {
|
2017-03-20 01:50:00 +00:00
|
|
|
public $method = "GET";
|
|
|
|
public $url = "";
|
|
|
|
public $type ="";
|
|
|
|
public $stream = "php://input";
|
2017-03-19 02:30:36 +00:00
|
|
|
|
|
|
|
function __construct(string $method = null, string $url = null, string $bodyStream = null, string $contentType = null) {
|
|
|
|
if(is_null($method)) $method = $_SERVER['REQUEST_METHOD'];
|
|
|
|
if(is_null($url)) $url = $_SERVER['REQUEST_URI'];
|
|
|
|
if(is_null($bodyStream)) $bodyStream = "php://input";
|
2017-03-20 01:50:00 +00:00
|
|
|
if(is_null($contentType)) {
|
|
|
|
if(isset($_SERVER['HTTP_CONTENT_TYPE'])) $contentType = $_SERVER['HTTP_CONTENT_TYPE'];
|
|
|
|
}
|
|
|
|
$this->method = strtoupper($method);
|
2017-03-19 02:30:36 +00:00
|
|
|
$this->url = $url;
|
|
|
|
$this->stream = $bodyStream;
|
|
|
|
$this->type = $contentType;
|
|
|
|
}
|
|
|
|
}
|