当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::header方法代码示例

本文整理汇总了PHP中Response::header方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::header方法的具体用法?PHP Response::header怎么用?PHP Response::header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response::header方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cat

 public function cat($file, \Response $oReponse = null)
 {
     $query_string = http_build_query(array());
     // récuperation de la requete
     require_once __DIR__ . "/Request.php";
     $oRequest = new Request();
     // lance la requete
     $response = $oRequest->send(array('verb' => 'GET', 'resource' => '/' . $this->_bucket . '/' . urlencode($file) . '?' . $query_string), $this->_auth);
     // vérification du code de retour
     if ($oRequest->info('http_code') !== 200) {
         // ouverture du flux xml
         require_once __DIR__ . "/XMLElement.php";
         throw new Client_Exception(new XMLElement($response), $oRequest);
     }
     // lecture du flux
     if ($oReponse !== null) {
         $oReponse->appendBody($response);
         $oReponse->type($oRequest->info('content_type'));
         // ajout des headers pour le validator HTTP
         $aHeaders = $oRequest->info('headers');
         $oReponse->header("ETag", $aHeaders['ETag']);
         $oReponse->header("Last-Modified", $aHeaders['Last-Modified']);
     }
     return $response;
 }
开发者ID:nlevee,项目名称:php-libs,代码行数:25,代码来源:Client.php

示例2: index

 public function index()
 {
     $title = $GLOBALS['Language']->getText('admin_main', 'configure_access_controls');
     $params = array('title' => $title);
     $renderer = TemplateRendererFactory::build()->getRenderer($this->getTemplateDir());
     $this->response->includeFooterJavascriptFile('/scripts/tuleap/admin-access-mode.js');
     $this->response->header($params);
     $renderer->renderToPage(self::TEMPLATE, new ForgeAccess_AdminPresenter($this->csrf, $title, $this->localincfinder->getLocalIncPath(), ForgeConfig::get(ForgeAccess::CONFIG), count($this->user_dao->searchByStatus(PFUser::STATUS_RESTRICTED)), ForgeConfig::get(User_ForgeUGroup::CONFIG_AUTHENTICATED_LABEL), ForgeConfig::get(User_ForgeUGroup::CONFIG_REGISTERED_LABEL), ForgeConfig::get(ForgeAccess::PROJECT_ADMIN_CAN_CHOOSE_VISIBILITY), ForgeConfig::get(ForgeAccess::REVERSE_PROXY_REGEXP)));
     $this->response->footer($params);
 }
开发者ID:pdaniel-frk,项目名称:tuleap,代码行数:10,代码来源:AdminController.php

示例3: index

 public function index()
 {
     $title = $GLOBALS['Language']->getText('admin_main', 'configure_homepage');
     $params = array('title' => $title);
     $renderer = TemplateRendererFactory::build()->getRenderer($this->getTemplateDir());
     $headlines = $this->getHeadlines();
     $this->response->includeFooterJavascriptFile('/scripts/tuleap/admin-homepage.js');
     $this->response->header($params);
     $renderer->renderToPage(self::TEMPLATE, new Admin_Homepage_Presenter($this->csrf, $title, $this->dao->isStandardHomepageUsed(), $headlines));
     $this->response->footer($params);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:11,代码来源:Controller.php

示例4: command

 /**
  * Call the Artisan  command
  *
  * @param  Request  $request
  * @param  string $command
  */
 public function command(Request $request, $command)
 {
     if (array_key_exists('argument_name', $request->all())) {
         $this->validate($request, ['argument_name' => 'required']);
     }
     if (array_key_exists('argument_id', $request->all())) {
         $this->validate($request, ['argument_id' => 'required']);
     }
     $inputs = $request->except('_token', 'command');
     $params = [];
     foreach ($inputs as $key => $value) {
         if ($value != '') {
             $name = starts_with($key, 'argument') ? substr($key, 9) : '--' . substr($key, 7);
             $params[$name] = $value;
         }
     }
     try {
         Artisan::call($command, $params);
         $output = Artisan::output();
         $http_code = 200;
     } catch (Exception $e) {
         $output = $e->getMessage();
         $http_code = 400;
     }
     if ($request->ajax()) {
         $response = new Response($output, $http_code);
         $response->header('Content-Type', 'text/plain');
         return $response;
     } else {
         return back()->with($http_code == 400 ? 'error' : 'output', $output);
     }
 }
开发者ID:ffogarasi,项目名称:nice-artisan,代码行数:38,代码来源:NiceArtisanController.php

示例5: to

 public static function to($url)
 {
     Response::clean();
     Response::header('Location', $url);
     Response::send();
     exit;
 }
开发者ID:evil-enterprises,项目名称:phpcore,代码行数:7,代码来源:Redirect.php

示例6: remove

 public function remove()
 {
     Response::header('Content-Type', 'application/json');
     // process post request
     if (Input::method() == 'POST') {
         Comments::remove();
     }
 }
开发者ID:reqshark,项目名称:anchor-cms,代码行数:8,代码来源:comments.php

示例7: rss

 public function rss()
 {
     // set headers
     Response::header('Content-Type', 'application/xml');
     // set content
     $xml = Rss::generate();
     // dump xml tree
     Response::content($xml);
 }
开发者ID:reqshark,项目名称:anchor-cms,代码行数:9,代码来源:routes.php

示例8: back

 public static function back()
 {
     if ($link = Filter::with('core.redirect', empty($_SERVER['HTTP_REFERER']) ? Request::get('redirect_uri', false) : $_SERVER['HTTP_REFERER'])) {
         Response::clean();
         Response::header('Location', $link);
         Response::send();
         exit;
     }
 }
开发者ID:caffeina-core,项目名称:core,代码行数:9,代码来源:Redirect.php

示例9: index

 public function index(CSRFSynchronizerToken $csrf, Response $response)
 {
     $title = $GLOBALS['Language']->getText('plugin_tracker_config', 'title');
     $params = array('title' => $title);
     $renderer = TemplateRendererFactory::build()->getRenderer(TRACKER_TEMPLATE_DIR);
     $response->header($params);
     $renderer->renderToPage(self::$TEMPLATE, new TrackerPluginConfigPresenter($csrf, $title, $this->localincfinder->getLocalIncPath(), $this->config));
     $response->footer($params);
 }
开发者ID:pkdevbox,项目名称:tuleap,代码行数:9,代码来源:TrackerPluginConfigController.php

示例10: bomb

 /**
  * Why do the bomb()?
  * This sets a generic plane for some nice low level logging
  * As opposed to extending the generic laravel response::json
  * This is /only/ called when there is an error.
  *
  * @param string $type
  * @param string $input
  * @param int    $code
  *
  * @return mixed
  */
 public function bomb($type = 'message', $input = 'Unspecified Error', $code = 404, $errors = [])
 {
     /*
      * Just as an example of the robustness of this function
      * this bomb sets success to 0 in all cases.
      * On the frontend, you simply have to check for the value of success
      * and if it is 0, you know an error occurred. (also note the non 200 return code)
      */
     $meta = ['RequestTimestamp' => (string) round($_SERVER["REQUEST_TIME_FLOAT"], 4), 'Duration' => (string) $this->executiontime(), 'ResponseTimestamp' => (string) round(microtime(true), 4)];
     $err = new stdClass();
     $err->Message = $type . ' ' . $input;
     $err->Meta = $errors;
     $err->Code = $code;
     $ErrMessage[] = $err;
     $output = ['Success' => false, 'Meta' => $meta, 'Errors' => $ErrMessage];
     $outp = json_encode($output, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     $out = json_encode($output, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
     // $response = (new Response($out, $code));
     $response = new Response($out);
     $response->header('Content-Type', 'application/json; charset=UTF-8');
     $response->header('Access-Control-Allow-Origin', '*');
     return $response;
 }
开发者ID:Neo-Desktop,项目名称:wm-browser,代码行数:35,代码来源:BaseController.php

示例11: build

 public function build($file)
 {
     Response::header('Content-Type', 'application/json; charset=utf-8');
     Response::content(json_encode(Lang::get($file)));
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:5,代码来源:lang.php

示例12: testFinalize

 /**
  * Test finalize
  *
  * Pre-conditions:
  * Case A: Response status is 200
  * Case B: Response status is 204
  * Case C: Response status is 304
  *
  * Post-conditions:
  * Case A: Response has body and content-length
  * Case B: Response does not have body and content-length
  * Case C: Response does not have body and content-length
  */
 public function testFinalize()
 {
     //Case A
     $r1 = new Response();
     $r1->body('body1');
     $r1->finalize();
     $this->assertEquals($r1->body(), 'body1');
     $this->assertEquals($r1->header('Content-Length'), 5);
     //Case B
     $r2 = new Response();
     $r2->body('body2');
     $r2->status(204);
     $r2->finalize();
     $this->assertEquals($r2->body(), '');
     $this->assertNull($r2->header('Content-Type'));
     //Case C
     $r3 = new Response();
     $r3->body('body3');
     $r3->status(304);
     $r3->finalize();
     $this->assertEquals($r3->body(), '');
     $this->assertNull($r3->header('Content-Type'));
 }
开发者ID:Jud,项目名称:Slim,代码行数:36,代码来源:ResponseTest.php

示例13: _readfile_laravel_chunked

 private function _readfile_laravel_chunked($path, $name = null, array $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     // Prepare the headers
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => \File::mime(\File::extension($path)), 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => \File::size($path)), $headers);
     $response = new \Response('', 200, $headers);
     $response->header('Content-Disposition', $response->disposition($name));
     // If there's a session we should save it now
     if (\Config::get('session.driver') !== '') {
         \Session::save();
     }
     // Send the headers and the file
     ob_end_clean();
     $response->send_headers();
     if ($fp = fread($path, 'rb')) {
         while (!feof($fp) and connection_status() == 0) {
             echo fread($fp, 8192);
             flush();
         }
     }
     // Finish off, like Laravel would
     \Event::fire('laravel.done', array($response));
     $response->foundation->finish();
     exit;
 }
开发者ID:microweber,项目名称:microweber,代码行数:27,代码来源:Files.php

示例14: testAddHeaderShouldAddHeaderToHeadersList

 public function testAddHeaderShouldAddHeaderToHeadersList()
 {
     $response = new Response();
     $response->header('some header');
     $this->assertContains('some header', $response->headers());
 }
开发者ID:holger,项目名称:yoshi,代码行数:6,代码来源:ResponseTest.php

示例15: parentHeader

 /**
  * Bypass location check
  * 
  * @param string $name
  * @param string $value
  * @return \Koldy\Response
  */
 private function parentHeader($name, $value = null)
 {
     return parent::header($name, $value);
 }
开发者ID:nkammah,项目名称:Crash-Analytics,代码行数:11,代码来源:Redirect.php


注:本文中的Response::header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。