public function getHeaders()
 {
     $headers = array();
     if (!$this->shouldStopForDebugging()) {
         $headers[] = array('Location', $this->uri);
     }
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'application/json'));
     if ($this->getClientURI()) {
         $headers[] = array('Location', $this->getFullURI());
     }
     // TODO -- T844 set headers with X-Auth-Scopes, etc
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function getHeaders()
 {
     $headers = array();
     if (!$this->shouldStopForDebugging()) {
         $uri = self::getURIForRedirect($this->uri, $this->isExternal);
         $headers[] = array('Location', $uri);
     }
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
Esempio n. 4
0
 /**
  * Write an entire @{class:AphrontResponse} to the output.
  *
  * @param AphrontResponse The response object to write.
  * @return void
  */
 public final function writeResponse(AphrontResponse $response)
 {
     // Build the content iterator first, in case it throws. Ideally, we'd
     // prefer to handle exceptions before we emit the response status or any
     // HTTP headers.
     $data = $response->getContentIterator();
     $all_headers = array_merge($response->getHeaders(), $response->getCacheHeaders());
     $this->writeHTTPStatus($response->getHTTPResponseCode(), $response->getHTTPResponseMessage());
     $this->writeHeaders($all_headers);
     $abort = false;
     foreach ($data as $block) {
         if (!$this->isWritable()) {
             $abort = true;
             break;
         }
         $this->writeData($block);
     }
     $response->didCompleteWrite($abort);
 }
Esempio n. 5
0
 public function getHeaders()
 {
     $headers = array(array('Content-Type', $this->getMimeType()));
     if (strlen($this->getDownload())) {
         $headers[] = array('X-Download-Options', 'noopen');
         $filename = $this->getDownload();
         $headers[] = array('Content-Disposition', 'attachment; filename=' . $filename);
     }
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function willSendResponse(AphrontResponse $response)
 {
     $request = $this->getRequest();
     $response->setRequest($request);
     if ($response instanceof AphrontDialogResponse) {
         if (!$request->isAjax()) {
             $view = new PhabricatorStandardPageView();
             $view->setRequest($request);
             $view->appendChild('<div style="padding: 2em 0;">' . $response->buildResponseString() . '</div>');
             $response = new AphrontWebpageResponse();
             $response->setContent($view->render());
             return $response;
         } else {
             return id(new AphrontAjaxResponse())->setContent(array('dialog' => $response->buildResponseString()));
         }
     } else {
         if ($response instanceof AphrontRedirectResponse) {
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('redirect' => $response->getURI()));
             }
         } else {
             if ($response instanceof Aphront404Response) {
                 $failure = new AphrontRequestFailureView();
                 $failure->setHeader('404 Not Found');
                 $failure->appendChild('<p>The page you requested was not found.</p>');
                 $view = new PhabricatorStandardPageView();
                 $view->setTitle('404 Not Found');
                 $view->setRequest($this->getRequest());
                 $view->appendChild($failure);
                 $response = new AphrontWebpageResponse();
                 $response->setContent($view->render());
                 $response->setHTTPResponseCode(404);
                 return $response;
             }
         }
     }
     return $response;
 }
Esempio n. 7
0
 /**
  * Write an entire @{class:AphrontResponse} to the output.
  *
  * @param AphrontResponse The response object to write.
  * @return void
  */
 public final function writeResponse(AphrontResponse $response)
 {
     // Do this first, in case it throws.
     $response_string = $response->buildResponseString();
     $all_headers = array_merge($response->getHeaders(), $response->getCacheHeaders());
     $this->writeHTTPStatus($response->getHTTPResponseCode(), $response->getHTTPResponseMessage());
     $this->writeHeaders($all_headers);
     $this->writeData($response_string);
 }
Esempio n. 8
0
 public function getHeaders()
 {
     $headers = array(array('Content-Type', $this->getMimeType()), array('Content-Length', strlen($this->buildResponseString())));
     if ($this->rangeMin || $this->rangeMax) {
         $len = strlen($this->content);
         $min = $this->rangeMin;
         $max = $this->rangeMax;
         $headers[] = array('Content-Range', "bytes {$min}-{$max}/{$len}");
     }
     if (strlen($this->getDownload())) {
         $headers[] = array('X-Download-Options', 'noopen');
         $filename = $this->getDownload();
         $headers[] = array('Content-Disposition', 'attachment; filename=' . $filename);
     }
     if ($this->allowOrigins) {
         $headers[] = array('Access-Control-Allow-Origin', implode(',', $this->allowOrigins));
     }
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function willSendResponse(AphrontResponse $response)
 {
     $request = $this->getRequest();
     $response->setRequest($request);
     if ($response instanceof AphrontDialogResponse) {
         if (!$request->isAjax()) {
             $view = new PhabricatorStandardPageView();
             $view->setRequest($request);
             $view->appendChild('<div style="padding: 2em 0;">' . $response->buildResponseString() . '</div>');
             $response = new AphrontWebpageResponse();
             $response->setContent($view->render());
             return $response;
         } else {
             return id(new AphrontAjaxResponse())->setContent(array('dialog' => $response->buildResponseString()));
         }
     } else {
         if ($response instanceof AphrontRedirectResponse) {
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('redirect' => $response->getURI()));
             }
         }
     }
     return $response;
 }
Esempio n. 10
0
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'text/plain; charset=UTF-8'));
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function getHeaders()
 {
     $this->readRequestHeaders();
     return array_merge(parent::getHeaders(), $this->headers, array(array('X-Phabricator-Proxy', 'true')));
 }
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'application/mercurial-0.1'));
     return array_merge(parent::getHeaders(), $headers);
 }
 public function renderHTMLFooter()
 {
     $data = array();
     if ($this->metadata) {
         $json_metadata = AphrontResponse::encodeJSONForHTTPResponse($this->metadata);
         $this->metadata = array();
     } else {
         $json_metadata = '{}';
     }
     // Even if there is no metadata on the page, Javelin uses the mergeData()
     // call to start dispatching the event queue.
     $data[] = 'JX.Stratcom.mergeData(' . $this->metadataBlock . ', ' . $json_metadata . ');';
     $onload = array();
     if ($this->behaviors) {
         $behaviors = $this->behaviors;
         $this->behaviors = array();
         $higher_priority_names = array('refresh-csrf', 'aphront-basic-tokenizer', 'dark-console', 'history-install');
         $higher_priority_behaviors = array_select_keys($behaviors, $higher_priority_names);
         foreach ($higher_priority_names as $name) {
             unset($behaviors[$name]);
         }
         $behavior_groups = array($higher_priority_behaviors, $behaviors);
         foreach ($behavior_groups as $group) {
             if (!$group) {
                 continue;
             }
             $group_json = AphrontResponse::encodeJSONForHTTPResponse($group);
             $onload[] = 'JX.initBehaviors(' . $group_json . ')';
         }
     }
     if ($onload) {
         foreach ($onload as $func) {
             $data[] = 'JX.onload(function(){' . $func . '});';
         }
     }
     if ($data) {
         $data = implode("\n", $data);
         return self::renderInlineScript($data);
     } else {
         return '';
     }
 }
 public function getHeaders()
 {
     $headers = array(array('Location', $this->uri));
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'text/plain'));
     return array_merge(parent::getHeaders(), $headers);
 }
Esempio n. 16
0
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'application/json'));
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
Esempio n. 17
0
 public function getHeaders()
 {
     return array_merge(parent::getHeaders(), $this->headers);
 }
 public function getHeaders()
 {
     $headers = array(array('Content-Type', 'application/vnd.git-lfs+json'));
     return array_merge(parent::getHeaders(), $headers);
 }
 public function willSendResponse(AphrontResponse $response)
 {
     $request = $this->getRequest();
     if ($response instanceof AphrontDialogResponse) {
         if (!$request->isAjax() && !$request->isQuicksand()) {
             $dialog = $response->getDialog();
             $title = $dialog->getTitle();
             $short = $dialog->getShortTitle();
             $crumbs = $this->buildApplicationCrumbs();
             $crumbs->addTextCrumb(coalesce($short, $title));
             $page_content = array($crumbs, $response->buildResponseString());
             $view = id(new PhabricatorStandardPageView())->setRequest($request)->setController($this)->setDeviceReady(true)->setTitle($title)->appendChild($page_content);
             $response = id(new AphrontWebpageResponse())->setContent($view->render())->setHTTPResponseCode($response->getHTTPResponseCode());
         } else {
             $response->getDialog()->setIsStandalone(true);
             return id(new AphrontAjaxResponse())->setContent(array('dialog' => $response->buildResponseString()));
         }
     } else {
         if ($response instanceof AphrontRedirectResponse) {
             if ($request->isAjax() || $request->isQuicksand()) {
                 return id(new AphrontAjaxResponse())->setContent(array('redirect' => $response->getURI()));
             }
         }
     }
     return $response;
 }
Esempio n. 20
0
 public function getHeaders()
 {
     $headers = array(array('Content-Type', $this->getMimeType()), array('Accept-Ranges', 'bytes'));
     if ($this->rangeMin || $this->rangeMax) {
         $len = $this->getContentLength();
         $min = $this->rangeMin;
         $max = $this->rangeMax;
         $headers[] = array('Content-Range', "bytes {$min}-{$max}/{$len}");
         $content_len = $max - $min + 1;
     } else {
         $content_len = $this->getContentLength();
     }
     $headers[] = array('Content-Length', $this->getContentLength());
     if (strlen($this->getDownload())) {
         $headers[] = array('X-Download-Options', 'noopen');
         $filename = $this->getDownload();
         $filename = addcslashes($filename, '"\\');
         $headers[] = array('Content-Disposition', 'attachment; filename="' . $filename . '"');
     }
     if ($this->allowOrigins) {
         $headers[] = array('Access-Control-Allow-Origin', implode(',', $this->allowOrigins));
     }
     $headers = array_merge(parent::getHeaders(), $headers);
     return $headers;
 }
 private function makeResponseCacheable(AphrontResponse $response)
 {
     $response->setCacheDurationInSeconds(60 * 60 * 24 * 30);
     $response->setLastModified(time());
     $response->setCanCDN(true);
     return $response;
 }
Esempio n. 22
0
 /**
  * Write an entire @{class:AphrontResponse} to the output.
  *
  * @param AphrontResponse The response object to write.
  * @return void
  */
 public final function writeResponse(AphrontResponse $response)
 {
     $all_headers = array_merge($response->getHeaders(), $response->getCacheHeaders());
     $this->writeHTTPStatus($response->getHTTPResponseCode());
     $this->writeHeaders($all_headers);
     $this->writeData($response->buildResponseString());
 }