updated depency libaries

This commit is contained in:
kremsy
2015-06-19 18:51:09 +02:00
parent 090830fa8c
commit 925b7a38a4
18 changed files with 207 additions and 56 deletions

View File

@ -54,7 +54,7 @@ class Request extends EventDispatcher implements RequestInterface
public function getOptions()
{
if (!isset($this->options)) {
$this->options = new Options;
$this->options = new Options();
}
return $this->options;
}
@ -97,6 +97,8 @@ class Request extends EventDispatcher implements RequestInterface
* This function should be called after initializing a cURL
* session and all the options for the session are set.
*
* Warning: it doesn't fire 'complete' event.
*
* @return Response
*/
public function send()
@ -113,32 +115,31 @@ class Request extends EventDispatcher implements RequestInterface
}
return $response;
}
protected function prepareQueue()
{
if (!isset($this->queue)) {
$request = $this;
$this->queue = new RequestsQueue;
$this->queue->addListener(
'complete',
function ($event) use ($request) {
$request->dispatch('complete', $event);
}
);
$this->queue->attach($this);
}
}
/**
* Creates new RequestsQueue with single Request attached to it
* and calls RequestsQueue::socketPerform() method.
*
* @see RequestsQueue::socketPerform()
*/
public function socketPerform()
{
$this->prepareQueue();
if (!isset($this->queue)) {
$this->queue = new RequestsQueue();
$this->queue->attach($this);
}
return $this->queue->socketPerform();
}
/**
* Calls socketSelect() on previously created RequestsQueue
*
* @see RequestsQueue::socketSelect()
*/
public function socketSelect($timeout = 1)
{
if (!isset($this->queue)) {
throw new Exception('Cannot select without perform before.');
throw new Exception('You need to call socketPerform() before.');
}
return $this->queue->socketSelect($timeout);
}