本文整理汇总了PHP中Zend_Controller_Response_Http::setHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Response_Http::setHeader方法的具体用法?PHP Zend_Controller_Response_Http::setHeader怎么用?PHP Zend_Controller_Response_Http::setHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Response_Http
的用法示例。
在下文中一共展示了Zend_Controller_Response_Http::setHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareDiscoveryParams
public static function prepareDiscoveryParams(array &$params, Zend_Controller_Response_Http $response, $topicType, $topicId, $selfLink, $subscriptionOption)
{
if (!bdApi_Option::getSubscription($topicType)) {
// subscription for this topic type has been disabled
return false;
}
// subscription discovery
$hubLink = bdApi_Data_Helper_Core::safeBuildApiLink('subscriptions', null, array('hub.topic' => bdApi_Model_Subscription::getTopic($topicType, $topicId), 'oauth_token' => ''));
$response->setHeader('Link', sprintf('<%s>; rel=hub', $hubLink));
$response->setHeader('Link', sprintf('<%s>; rel=self', $selfLink));
// subscription info
if (!empty($subscriptionOption)) {
$subscriptionOption = @unserialize($subscriptionOption);
if (!empty($subscriptionOption['subscriptions'])) {
/* @var $session bdApi_Session */
$session = XenForo_Application::getSession();
$clientId = $session->getOAuthClientId();
foreach ($subscriptionOption['subscriptions'] as $subscription) {
if ($subscription['client_id'] == $clientId) {
$params['subscription_callback'] = $subscription['callback'];
}
}
}
}
return true;
}
示例2: send
/**
* Send the file to the client (Download)
*
* @param string|array $options Options for the file(s) to send
* @return void
*/
public function send($options = null)
{
if (is_string($options)) {
$filepath = $options;
} else {
if (is_array($options)) {
$filepath = $options['filepath'];
} else {
throw new Exception("Filename is not set.");
}
}
if (!is_file($filepath) || !is_readable($filepath)) {
throw new Exception("File '{$filepath}' does not exists.");
}
$mimeType = $this->_detectMimeType(array('name' => $filepath));
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-length', filesize($filepath));
$response->setHeader('Content-Type', $mimeType);
$response->sendHeaders();
$handle = fopen($filepath, 'r');
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
echo $buffer;
}
if (!feof($handle)) {
throw new Exception("Error: unexpected fgets() fail.");
}
fclose($handle);
}
}
示例3: __construct
/**
* Constructor.
*
* @param XenForo_Dependencies_Abstract
* @param Zend_Controller_Response_Http
* @param Zend_Controller_Request_Http
*/
public function __construct(XenForo_Dependencies_Abstract $dependencies, Zend_Controller_Response_Http $response, Zend_Controller_Request_Http $request)
{
$this->_dependencies = $dependencies;
$this->_response = $response;
$this->_request = $request;
if (!XenForo_Application::isRegistered('config') || XenForo_Application::getConfig()->enableClickjackingProtection) {
$this->_response->setHeader('X-Frame-Options', 'SAMEORIGIN');
}
$this->_preloadContainerData();
}
示例4: _initResponseCharset
/**
* Creates a response object, sets the Content-Type header and assigns the
* response to the front controller.
*
* @return null
*/
protected function _initResponseCharset()
{
$front = Zend_Controller_Front::getInstance();
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-Type', 'text/html; charset=utf-8', false);
$front->setResponse($response);
}
示例5: _initResponse
/** Initialise the response and set gzip status
*/
protected function _initResponse()
{
$response = new Zend_Controller_Response_Http();
$response->setHeader('X-Powered-By', 'Dan\'s magic army of elves')->setHeader('Host', 'finds.org.uk')->setHeader('X-Compression', 'gzip')->setHeader('Accept-Encoding', 'gzip, deflate')->setHeader('Expires', gmdate('D, d M Y H:i:s', time() + 2 * 3600) . ' GMT', true);
$frontController = Zend_Controller_Front::getInstance();
$frontController->setResponse($response);
}
示例6: _initFrontControllerOutput
protected function _initFrontControllerOutput()
{
$front = $this->bootstrap('FrontController')->getResource('FrontController');
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
$front->setResponse($response);
}
示例7: _challengeClient
/**
* Challenge Client
*
* Sets a 401 or 407 Unauthorized response code, and creates the
* appropriate Authenticate header(s) to prompt for credentials.
*
* @return Zend_Auth_Result Always returns a non-identity Auth result
*/
protected function _challengeClient()
{
if ($this->_imaProxy) {
$statusCode = 407;
$headerName = 'Proxy-Authenticate';
} else {
$statusCode = 401;
$headerName = 'WWW-Authenticate';
}
$this->_response->setHttpResponseCode($statusCode);
// Send a challenge in each acceptable authentication scheme
if (in_array('basic', $this->_acceptSchemes)) {
$this->_response->setHeader($headerName, $this->_basicHeader());
}
if (in_array('digest', $this->_acceptSchemes)) {
$this->_response->setHeader($headerName, $this->_digestHeader());
}
return new Zend_Auth_Result(
Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
array(),
array('Invalid or absent credentials; challenging client')
);
}
示例8: init
public function init()
{
$registry = Zend_Registry::getInstance();
$config = $registry->get("config");
$sysCache = $registry->get("sysCache");
$cacheFiles = new Ml_Cache_Files($sysCache);
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers');
$frontController = $this->getBootstrap()->getResource('FrontController');
$dispatcher = $frontController->getDispatcher();
$request = $frontController->getRequest();
$router = $frontController->getRouter();
$router->removeDefaultRoutes();
$compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
$router->addRoute(HOST_MODULE, $compat);
$routerConfig = $cacheFiles->getConfigIni(APPLICATION_PATH . '/configs/' . HOST_MODULE . 'Routes.ini');
$router->addConfig($routerConfig, "apiroutes");
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers/helpers');
$loadOauthStore = Zend_Controller_Action_HelperBroker::getStaticHelper("LoadOauthstore");
$loadOauthStore->setinstance();
$loadOauthStore->preloadServer();
$frontController->setBaseUrl($config['apiroot'])->setParam('noViewRenderer', true)->addModuleDirectory(APPLICATION_PATH . '/modules')->addControllerDirectory(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers');
$response = new Zend_Controller_Response_Http();
if (filter_input(INPUT_GET, "responseformat", FILTER_UNSAFE_RAW) == 'json') {
$contentType = 'application/json';
} else {
$contentType = 'text/xml';
}
$response->setHeader('Content-Type', $contentType . '; charset=utf-8', true);
$frontController->setResponse($response);
}
示例9: renderDebugOutput
/**
* Renders page-level debugging output and replaces the original view content
* with it. Alternatively, it could inject itself into the view content.
*
* @param string $originalContent Original, rendered view content
*
* @return string Replacement rendered view content
*/
public function renderDebugOutput($originalContent)
{
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(200);
$this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
$this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
return XenForo_Debug::getDebugPageWrapperHtml(XenForo_Debug::getDebugHtml());
}
示例10: _challengeClient
/**
* Challenge Client
*
* Sets a 401 Unauthorized response code, and creates the
* appropriate Authenticate header(s) to prompt for credentials.
*
* @return Zend_Auth_Result Always returns a non-identity Auth result
*/
protected function _challengeClient()
{
$this->_response->setHttpResponseCode(401);
// Send a challenge in each acceptable authentication scheme
foreach ($this->_schemes as $scheme => $callback) {
$this->_response->setHeader('WWW-Authenticate', $scheme);
}
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Invalid or absent credentials; challenging client'));
}
示例11: _initResponse
protected function _initResponse()
{
$options = $this->getOptions();
if (!isset($options['response']['defaultContentType'])) {
return;
}
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-Type', $options['response']['defaultContentType'], true);
$this->bootstrap('FrontController');
$this->getResource('FrontController')->setResponse($response);
}
示例12: setDownloadFileName
/**
* Tells the browser that the data should be downloaded (rather than displayed)
* using the specified file name.
*
* @param string $fileName
* @param boolean $inline True if the attachment should be shown inline - use with caution!
*/
public function setDownloadFileName($fileName, $inline = false)
{
$type = $inline ? 'inline' : 'attachment';
$fileName = str_replace('"', '', $fileName);
if (preg_match('/[\\x80-\\xFF]/', $fileName)) {
$altNamePart = "; filename*=UTF-8''" . rawurlencode($fileName);
} else {
$altNamePart = '';
}
$this->_response->setHeader('Content-Disposition', $type . '; filename="' . str_replace('"', '', $fileName) . '"' . $altNamePart, true);
}
示例13: _initResponse
protected function _initResponse()
{
// Ensure front controller instance is present, and fetch it
$this->bootstrap('FrontController');
$front = $this->getResource('FrontController');
/* @var $front Zend_Controller_Front */
// Initialize and set the response object
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
$front->setResponse($response);
return $response;
}
示例14: _challengeClient
/**
* Challenge Client
*
* Sets a 401 or 407 Unauthorized response code, and creates the
* appropriate Authenticate header(s) to prompt for credentials.
*
* @return Zend_Auth_Result Always returns a non-identity Auth result
*/
protected function _challengeClient()
{
if ($this->_imaProxy) {
$statusCode = 407;
$headerName = 'Proxy-Authenticate';
} else {
$statusCode = 401;
$headerName = 'WWW-Authenticate';
}
$this->_response->setHttpResponseCode($statusCode);
$this->_response->setHeader($headerName, $this->_getAuthHeader());
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Invalid or absent credentials; challenging client'));
}
示例15: _initModifiedFrontController
protected function _initModifiedFrontController()
{
$options = $this->getOption('resources');
if (!isset($options['modifiedFrontController']['contentType'])) {
return;
}
$this->bootstrap('FrontController');
$front = $this->getResource('FrontController');
//$front->addModuleDirectory(APPLICATION_PATH . '/modules');
$response = new Zend_Controller_Response_Http();
$response->setHeader('Content-Type', $options['modifiedFrontController']['contentType'], true);
$front->setResponse($response);
}