本文整理汇总了PHP中SS_HTTPResponse::removeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPResponse::removeHeader方法的具体用法?PHP SS_HTTPResponse::removeHeader怎么用?PHP SS_HTTPResponse::removeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPResponse
的用法示例。
在下文中一共展示了SS_HTTPResponse::removeHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ok
protected function ok(array $res = null, $use_etag = true)
{
$response = new SS_HTTPResponse();
$response->setStatusCode(200);
$response->addHeader('Content-Type', 'application/json');
if (is_null($res)) {
$res = array();
}
$response->setBody(json_encode($res));
//conditional get Request (etags)
$request = Controller::curr()->getRequest();
if ($request->isGET() && $use_etag) {
$etag = md5($response->getBody());
$requestETag = $request->getHeader('If-None-Match');
foreach (array('Expires', 'Cache-Control') as $header) {
$response->removeHeader($header);
}
$lastmod = gmdate('D, d M Y 0:0:0 \\G\\M\\T', time());
$response->addHeader('Cache-Control', 'max-age=3600');
$response->addHeader('Last-Modified', $lastmod);
$response->addHeader('Expires', gmdate('D, d M Y H:m:i \\G\\M\\T', time() + 3600));
$response->addHeader('ETag', $etag);
if (!empty($requestETag) && $requestETag == $etag) {
$response->setStatusCode(304);
$response->addHeader('ETag', $etag);
$response->setBody(null);
}
}
return $response;
}
示例2: applyToResponse
/**
* @param Object $originator
* @param SS_HTTPRequest $request
* @param SS_HTTPResponse $response
* @param DataModel $model
*/
public function applyToResponse($originator, SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
{
foreach ($this->headers as $key => $value) {
if ($value !== "") {
$response->addHeader($key, $value);
} else {
$response->removeHeader($key);
}
}
}
示例3: ok
protected function ok(array $res = null)
{
$response = new SS_HTTPResponse();
$response->setStatusCode(200);
$response->addHeader('Content-Type', 'application/json');
if (is_null($res)) {
$res = array();
}
$response->setBody(json_encode($res));
//conditional get Request (etags)
$request = Controller::curr()->getRequest();
if ($request->isGET()) {
$etag = md5($response->getBody());
$requestETag = $request->getHeader('If-None-Match');
if (!empty($requestETag) && $requestETag == $etag) {
$response->setStatusCode(304);
foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) {
$response->removeHeader($header);
}
$response->setBody(null);
} else {
$response->addHeader('ETag', $etag);
}
}
return $response;
}