-
-
Save nextend/61bb5a8b36ea126f3e95297f3f7de10e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Test { | |
protected $handle; | |
protected $data = ''; | |
private $chunkIndex = 0; | |
public function __construct() { | |
$url = "*****"; | |
$this->handle = curl_init($url); | |
curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array( | |
$this, | |
'stream_body' | |
)); | |
curl_setopt($this->handle, CURLOPT_BUFFERSIZE, 1160); | |
curl_exec($this->handle); | |
curl_close($this->handle); | |
$md5 = md5($this->data); | |
if ($md5 !== '231732259d67fe83ed6fc02d7ad9be57') { | |
echo "<h1>Error, not valid md5</h1>"; | |
} | |
echo "<h1>" . $md5 . "</h1>"; | |
} | |
public function stream_body($handle, $data) { | |
$data_length = strlen($data); | |
$this->data.= $data; | |
echo 'Chunk #' . ($this->chunkIndex++) . ': ' . md5($data) . ' '.$data_length.'<br>'; | |
return $data_length; | |
} | |
} | |
new Test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment