projects
/
pharext
/
pharext.org
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
02fda98
)
github: honor redirect in readrepo
author
Michael Wallner
<mike@php.net>
Fri, 16 Dec 2016 09:15:21 +0000
(10:15 +0100)
committer
Michael Wallner
<mike@php.net>
Fri, 20 Dec 2019 12:21:59 +0000
(13:21 +0100)
app/Github/API/Repos/ReadRepo.php
patch
|
blob
|
history
diff --git
a/app/Github/API/Repos/ReadRepo.php
b/app/Github/API/Repos/ReadRepo.php
index 15c0314e9243ae935e23fc718b7f16b368317283..00b9d2ce6fdc4488e9528189221ff700362fce20 100644
(file)
--- a/
app/Github/API/Repos/ReadRepo.php
+++ b/
app/Github/API/Repos/ReadRepo.php
@@
-11,17
+11,35
@@
class ReadRepo extends Call
{
function request() {
$url = $this->url->mod(uri_template("./repos/{+repo}", $this->args));
{
function request() {
$url = $this->url->mod(uri_template("./repos/{+repo}", $this->args));
+ return $this->requestUrl($url);
+ }
+
+ function requestUrl($url) {
$request = new Request("GET", $url, [
"Authorization" => "token " . $this->api->getToken(),
"Accept" => $this->config->api->accept,
]);
return $request;
}
$request = new Request("GET", $url, [
"Authorization" => "token " . $this->api->getToken(),
"Accept" => $this->config->api->accept,
]);
return $request;
}
-
+
function response(Response $response) {
if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
throw new RequestException($response);
}
function response(Response $response) {
if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
throw new RequestException($response);
}
+ if ($response->getResponseCode() >= 300 && $response->getResponseCode() < 400) {
+ $this->api->getClient()->enqueue(
+ $this->requestUrl($json->url),
+ function($response) {
+ try {
+ $this->deferred->resolve($this->response($response));
+ } catch (\Exception $e) {
+ $this->deferred->reject($e);
+ }
+ return true;
+ }
+ );
+ return $this->deferred->promise();
+ }
$result = [$json];
$this->saveToCache($result);
return $result;
$result = [$json];
$this->saveToCache($result);
return $result;