formatted
This commit is contained in:
parent
545ee6bc25
commit
f369af1358
@ -3,7 +3,6 @@
|
|||||||
namespace ManiaControl\Files;
|
namespace ManiaControl\Files;
|
||||||
|
|
||||||
use cURL\Event;
|
use cURL\Event;
|
||||||
use cURL\Exception;
|
|
||||||
use cURL\Request;
|
use cURL\Request;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
@ -36,16 +35,28 @@ class AsynchronousFileReader {
|
|||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function newRequestTest($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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append available Data of active Requests
|
* Append available Data of active Requests
|
||||||
*/
|
*/
|
||||||
public function appendData() {
|
public function appendData() {
|
||||||
foreach ($this->requests as $key => $request) {
|
foreach ($this->requests as $key => $request) {
|
||||||
if ($request->socketPerform()) {
|
if ($request->socketPerform()) {
|
||||||
$request->socketSelect();
|
$request->socketSelect();
|
||||||
}else{
|
} else {
|
||||||
unset($this->requests[$key]);
|
unset($this->requests[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +114,8 @@ class AsynchronousFileReader {
|
|||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO remove, they are just for testing dedimania
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a Request to the queue
|
* Add a Request to the queue
|
||||||
*
|
*
|
||||||
@ -112,19 +125,6 @@ class AsynchronousFileReader {
|
|||||||
array_push($this->requests, $request);
|
array_push($this->requests, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO remove, they are just for testing dedimania
|
|
||||||
public static function newRequestTest($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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postDataTest(Request $request, $url, callable $function, $content, $compression = false,
|
public function postDataTest(Request $request, $url, callable $function, $content, $compression = false,
|
||||||
$contentType = 'text/xml; charset=UTF-8;') {
|
$contentType = 'text/xml; charset=UTF-8;') {
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class AsynchronousFileReader {
|
|||||||
->set(CURLOPT_POST, true) // post method
|
->set(CURLOPT_POST, true) // post method
|
||||||
->set(CURLOPT_POSTFIELDS, $content) // post content field
|
->set(CURLOPT_POSTFIELDS, $content) // post content field
|
||||||
->set(CURLOPT_HTTPHEADER, $headers) // headers
|
->set(CURLOPT_HTTPHEADER, $headers) // headers
|
||||||
;
|
;
|
||||||
$request->addListener('complete', function (Event $event) use (&$function) {
|
$request->addListener('complete', function (Event $event) use (&$function) {
|
||||||
$error = null;
|
$error = null;
|
||||||
$content = null;
|
$content = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user