projects
/
m6w6
/
seekat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (from parent 1:
21ffa2d
)
compatibility with 2.6.0 and 3.1.0
author
Michael Wallner
<mike@php.net>
Mon, 22 Aug 2016 13:49:38 +0000
(15:49 +0200)
committer
Michael Wallner
<mike@php.net>
Mon, 22 Aug 2016 13:49:38 +0000
(15:49 +0200)
lib/API.php
patch
|
blob
|
history
lib/API/Call.php
patch
|
blob
|
history
diff --git
a/lib/API.php
b/lib/API.php
index ba384c5ad4eb0d591ebc3a1aa671099b841214b9..1fd3da011150fdfa0c3d20216b69da24a95553df 100644
(file)
--- a/
lib/API.php
+++ b/
lib/API.php
@@
-3,6
+3,7
@@
namespace seekat;
use Countable;
namespace seekat;
use Countable;
+use Exception;
use Generator;
use http\{
Client,
use Generator;
use http\{
Client,
@@
-155,10
+156,16
@@
class API implements IteratorAggregate, Countable {
}
/* fetch resource, unless already localized, and try for {$method}_url */
}
/* fetch resource, unless already localized, and try for {$method}_url */
- return $this->$method->get(...$args)->otherwise(function(Throwable $error) use($method, $args) {
+ return $this->$method->get(...$args)->otherwise(function($error) use($method, $args) {
+ if ($error instanceof Throwable) {
+ $message = $error->getMessage();
+ } else {
+ $message = $error;
+ $error = new Exception($error);
+ }
if ($this->exists($method."_url", $url)) {
if ($this->exists($method."_url", $url)) {
- $this->__log->info(__FUNCTION__."($method): ". $
error->getMessage()
, [
+ $this->__log->info(__FUNCTION__."($method): ". $
message
, [
"url" => (string) $this->__url
]);
"url" => (string) $this->__url
]);
@@
-166,7
+173,7
@@
class API implements IteratorAggregate, Countable {
return $this->withUrl($url)->get(...$args);
}
return $this->withUrl($url)->get(...$args);
}
- $this->__log->error(__FUNCTION__."($method): ". $
error->getMessage()
, [
+ $this->__log->error(__FUNCTION__."($method): ". $
message
, [
"url" => (string) $this->__url
]);
"url" => (string) $this->__url
]);
diff --git
a/lib/API/Call.php
b/lib/API/Call.php
index 787f98db3b24238654bf1a42e0d628247cdc1ed5..26a52ee0995fbff2807d3e4ab850ca97f157eea9 100644
(file)
--- a/
lib/API/Call.php
+++ b/
lib/API/Call.php
@@
-56,7
+56,14
@@
class Call extends Deferred implements SplObserver
});
$client->attach($this);
});
$client->attach($this);
- $client->enqueue($request);
+ $client->enqueue($request, function(Response $response) {
+ $this->response = $response;
+ $this->complete(
+ [$this, "resolve"],
+ [$this, "reject"]
+ );
+ return true;
+ });
/* start off */
$client->once();
}
/* start off */
$client->once();
}
@@
-76,14
+83,6
@@
class Call extends Deferred implements SplObserver
}
$this->notify((object) compact("client", "request", "progress"));
}
$this->notify((object) compact("client", "request", "progress"));
-
- if ($progress->info === "finished") {
- $this->response = $this->client->getResponse();
- $this->complete(
- [$this, "resolve"],
- [$this, "reject"]
- );
- }
}
/**
}
/**
@@
-101,10
+100,8
@@
class Call extends Deferred implements SplObserver
$reject($e);
}
} else {
$reject($e);
}
} else {
- $reject($this->client->getTransferInfo($this->request)
["error"]
);
+ $reject($this->client->getTransferInfo($this->request)
->error
);
}
}
-
- $this->client->dequeue($this->request);
}
/**
}
/**