Browse Source

pass through http response code

pull/39/head
Aaron Parecki 4 years ago
parent
commit
6733145b47
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 8 additions and 8 deletions
  1. +4
    -4
      controllers/Parse.php
  2. +4
    -4
      lib/Formats/GitHub.php

+ 4
- 4
controllers/Parse.php View File

@ -365,17 +365,17 @@ class Parse {
$json = $request->get('json');
if($json) {
// Accept GitHub JSON and parse that if provided
list($data, $json) = Formats\GitHub::parse($this->http, $url, null, $json);
list($data, $json, $code) = Formats\GitHub::parse($this->http, $url, null, $json);
} else {
// Otherwise fetch the post unauthenticated or with the provided access token
list($data, $json) = Formats\GitHub::parse($this->http, $url, $creds);
list($data, $json, $code) = Formats\GitHub::parse($this->http, $url, $creds);
}
if($data) {
if($request->get('include_original'))
$data['original'] = $json;
$data['url'] = $url;
$data['code'] = 200;
$data['code'] = $code;
return $this->respond($response, 200, $data);
} else {
return $this->respond($response, 200, [
@ -383,7 +383,7 @@ class Parse {
'type' => 'unknown'
],
'url' => $url,
'code' => 0
'code' => $code
]);
}
}

+ 4
- 4
lib/Formats/GitHub.php View File

@ -40,12 +40,12 @@ class GitHub {
$apiurl = 'https://api.github.com/repos/'.$org.'/'.$repo.'/issues/comments/'.$comment;
} else {
return [null, null];
return [null, null, 0];
}
$response = $http->get($apiurl, ['User-Agent: XRay ('.Config::$base.')']);
if($response['code'] != 200) {
return [null, $response['body']];
return [null, $response['body'], $response['code']];
}
$data = json_decode($response['body'], true);
@ -54,7 +54,7 @@ class GitHub {
}
if(!$data) {
return [null, null];
return [null, null, 0];
}
// Start building the h-entry
@ -110,7 +110,7 @@ class GitHub {
'data' => $entry
];
return [$response, $json];
return [$response, $json, $response['code']];
}
}

Loading…
Cancel
Save