Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Jun 10, 2024
1 parent 95c3250 commit 0c95a7d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/libraries/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,21 +527,19 @@ public function isValidIP(?string $ip = null): bool
$Ip = new \Validation\Rules\Ip();
return ($Ip->validate($ip));
}

/**
* Gets the content type of an HTTP request
*/
public function getContentType(): ?string
{
$contentType = null;
$contentType = $_SERVER['CONTENT_TYPE'] ?? $_SERVER['HTTP_CONTENT_TYPE'] ?? null;

if (isset($_SERVER['CONTENT_TYPE'])) {
$contentType = $_SERVER['CONTENT_TYPE'];
} elseif (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
$contentType = $_SERVER['HTTP_CONTENT_TYPE'];
if (!$contentType) {
return null;
}

return $contentType;
$parts = explode(';', $contentType);
return trim($parts[0]); // trim to remove any whitespace
}

/**
Expand Down

0 comments on commit 0c95a7d

Please sign in to comment.