diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 3245246c6..6cde97c18 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -42,7 +42,13 @@ final class Rest throw new \Exception(); } + curl_setopt($curl, CURLOPT_NOBODY, true); + curl_setopt($curl, CURLOPT_HEADER, false); + switch ($request->getMethod()) { + case RequestMethod::GET: + curl_setopt($curl, CURLOPT_HTTPGET, true); + break; case RequestMethod::PUT: \curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); break; @@ -59,8 +65,10 @@ final class Rest } } - \curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - \curl_setopt($curl, CURLOPT_USERPWD, 'username:password'); + if ($request->getUri()->getUser() !== '') { + \curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + \curl_setopt($curl, CURLOPT_USERPWD, $request->getUri()->getUserInfo()); + } \curl_setopt($curl, CURLOPT_URL, $request->__toString()); \curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); diff --git a/Security/PhpCode.php b/Security/PhpCode.php index b3d403141..a6ca86393 100644 --- a/Security/PhpCode.php +++ b/Security/PhpCode.php @@ -156,4 +156,19 @@ final class PhpCode { return \md5_file($source) === $hash; } + + /** + * Validate code integrety + * + * @param string $source Source code + * @param string $remote Remote code + * + * @return bool + * + * @since 1.0.0 + */ + public static function validateStringIntegrity(string $source, string $remote) : bool + { + return $source === $remote; + } }