Fix download and code inspection bugs

This commit is contained in:
Dennis Eichhorn 2018-07-31 18:24:49 +02:00
parent 6a14f221ee
commit 57da54ad44
2 changed files with 25 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}
}