Change of condition "content-type" #22
@@ -324,13 +324,16 @@ final class request
|
|||||||
bool $environment = false
|
bool $environment = false
|
||||||
) {
|
) {
|
||||||
// Writing method from argument into the property
|
// Writing method from argument into the property
|
||||||
if (isset($method)) $this->method = $method;
|
if (isset($method))
|
||||||
|
$this->method = $method;
|
||||||
|
|
||||||
// Writing URI from argument into the property
|
// Writing URI from argument into the property
|
||||||
if (isset($uri)) $this->uri = $uri;
|
if (isset($uri))
|
||||||
|
$this->uri = $uri;
|
||||||
|
|
||||||
// Writing verstion of HTTP protocol from argument into the property
|
// Writing verstion of HTTP protocol from argument into the property
|
||||||
if (isset($protocol)) $this->protocol = $protocol;
|
if (isset($protocol))
|
||||||
|
$this->protocol = $protocol;
|
||||||
|
|
||||||
if (isset($headers)) {
|
if (isset($headers)) {
|
||||||
// Received headers
|
// Received headers
|
||||||
@@ -363,10 +366,12 @@ final class request
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Writing parameters from argument into the property
|
// Writing parameters from argument into the property
|
||||||
if (isset($parameters)) $this->parameters = $parameters;
|
if (isset($parameters))
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
|
||||||
// Writing files from argument into the property
|
// Writing files from argument into the property
|
||||||
if (isset($files)) $this->files = $files;
|
if (isset($files))
|
||||||
|
$this->files = $files;
|
||||||
|
|
||||||
if ($environment) {
|
if ($environment) {
|
||||||
// Requested to write values from environment
|
// Requested to write values from environment
|
||||||
@@ -410,7 +415,7 @@ final class request
|
|||||||
unset($buffer);
|
unset($buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_starts_with($this->headers['content-type'], content::json->value)) {
|
if (str_starts_with($this->headers['content-type'] ?? '', content::json->value)) {
|
||||||
// The body contains "application/json"
|
// The body contains "application/json"
|
||||||
|
|
||||||
// Initializing data from the input buffer
|
// Initializing data from the input buffer
|
||||||
@@ -467,8 +472,10 @@ final class request
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validating of required properties
|
// Validating of required properties
|
||||||
if (empty($this->method)) throw new exception_argument('Failed to initialize method of the request', status::internal_server_error->value);
|
if (empty($this->method))
|
||||||
if (empty($this->uri)) throw new exception_argument('Failed to initialize URI of the request', status::internal_server_error->value);
|
throw new exception_argument('Failed to initialize method of the request', status::internal_server_error->value);
|
||||||
|
if (empty($this->uri))
|
||||||
|
throw new exception_argument('Failed to initialize URI of the request', status::internal_server_error->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user