Differential D21120 Diff 50299 src/applications/conduit/controller/PhabricatorConduitAPIController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/controller/PhabricatorConduitAPIController.php
| Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | switch ($request->getStr('output')) { | ||||
| case 'human': | case 'human': | ||||
| return $this->buildHumanReadableResponse( | return $this->buildHumanReadableResponse( | ||||
| $method, | $method, | ||||
| $api_request, | $api_request, | ||||
| $response->toDictionary(), | $response->toDictionary(), | ||||
| $method_implementation); | $method_implementation); | ||||
| case 'json': | case 'json': | ||||
| default: | default: | ||||
| return id(new AphrontJSONResponse()) | $response = id(new AphrontJSONResponse()) | ||||
| ->setAddJSONShield(false) | ->setAddJSONShield(false) | ||||
| ->setContent($response->toDictionary()); | ->setContent($response->toDictionary()); | ||||
| $capabilities = $this->getConduitCapabilities(); | |||||
| if ($capabilities) { | |||||
| $capabilities = implode(' ', $capabilities); | |||||
| $response->addHeader('X-Conduit-Capabilities', $capabilities); | |||||
| } | |||||
| return $response; | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Authenticate the client making the request to a Phabricator user account. | * Authenticate the client making the request to a Phabricator user account. | ||||
| * | * | ||||
| * @param ConduitAPIRequest Request being executed. | * @param ConduitAPIRequest Request being executed. | ||||
| * @param dict Request metadata. | * @param dict Request metadata. | ||||
| ▲ Show 20 Lines • Show All 563 Lines • ▼ Show 20 Lines | private function authorizeOAuthMethodAccess( | ||||
| $authorization_scope = $authorization->getScope(); | $authorization_scope = $authorization->getScope(); | ||||
| if (!empty($authorization_scope[$required_scope])) { | if (!empty($authorization_scope[$required_scope])) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| private function getConduitCapabilities() { | |||||
| $capabilities = array(); | |||||
| if (AphrontRequestStream::supportsGzip()) { | |||||
| $capabilities[] = 'gzip'; | |||||
| } | |||||
| return $capabilities; | |||||
| } | |||||
| } | } | ||||