file reader fix
This commit is contained in:
parent
07fa365d1a
commit
3f7c4a50a6
@ -103,7 +103,7 @@ class AsyncHttpRequest {
|
||||
* @param Request $request
|
||||
*/
|
||||
private function processRequest(Request $request) {
|
||||
$request->addListener('complete', function (Event $event) use (&$function) {
|
||||
$request->addListener('complete', function (Event $event) {
|
||||
$error = null;
|
||||
$content = null;
|
||||
if ($event->response->hasError()) {
|
||||
@ -111,10 +111,10 @@ class AsyncHttpRequest {
|
||||
} else {
|
||||
$content = $event->response->getContent();
|
||||
}
|
||||
call_user_func($function, $content, $error);
|
||||
call_user_func($this->function, $content, $error);
|
||||
});
|
||||
|
||||
$fileReader = new AsynchronousFileReader($this->maniaControl);
|
||||
$fileReader = $this->maniaControl->getFileReader();
|
||||
$fileReader->addRequest($request);
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,24 @@ class AsynchronousFileReader {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new cURL Request for the given URL, DO NOT CALL MANUALLY!
|
||||
*
|
||||
* @param string $url
|
||||
* @return Request
|
||||
*/
|
||||
public function newRequest($url) {
|
||||
$request = new Request($url);
|
||||
$request->getOptions()->set(CURLOPT_TIMEOUT, 60)->set(CURLOPT_HEADER, false)// don't display response header
|
||||
->set(CURLOPT_CRLF, true)// linux line feed
|
||||
->set(CURLOPT_ENCODING, '')// accept encoding
|
||||
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION)// user-agent
|
||||
->set(CURLOPT_RETURNTRANSFER, true); // return instead of output content
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load a Remote File
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user