content = $content; return $this; } private function getContent() { return $this->content; } private function setURI($uri) { $this->uri = $uri; return $this; } private function getURI() { return $this->uri; } public function setMalformed($malformed) { if ($malformed) { $this->setHTTPResponseCode(400); $this->setContent(array('error' => $malformed)); } return $this; } public function setNotFound($not_found) { if ($not_found) { $this->setHTTPResponseCode(404); $this->setContent(array('error' => $not_found)); } return $this; } public function setRedirect(PhutilURI $uri) { if ($uri) { $this->setHTTPResponseCode(302); $this->setURI($uri); $this->setContent(null); } return $this; } public function __construct() { $this->setHTTPResponseCode(200); return $this; } public function getHeaders() { $headers = array( array('Content-Type', 'application/json'), ); if ($this->getURI()) { $headers[] = array('Location', $this->getURI()); } // TODO -- T844 set headers with X-Auth-Scopes, etc $headers = array_merge(parent::getHeaders(), $headers); return $headers; } public function buildResponseString() { $content = $this->getContent(); if ($content) { return $this->encodeJSONForHTTPResponse($content); } return ''; } }