<commit_before><?php
class CHttpCacheFilter extends CFilter
{
	/**
	 * Timestamp for the last modification date. Must be a string parsable by {@link http://php.net/strtotime strtotime()}.
	 * @var string
	 */
	public $lastModified;

	/**
	 * Expression for the last modification date. If set, this takes precedence over {@link lastModified}.
	 * @var string|callback
	 */
	public $lastModifiedExpression;
	/**
	 * Seed for the ETag. Can be anything that passes through {@link http://php.net/serialize serialize()}.
	 * @var mixed
	 */
	public $etagSeed;
	
	/**
	 * Expression for the ETag seed. If set, this takes precedence over {@link etag}. 
	 * @var string|callback
	 */
	public $etagSeedExpression;

	/**
	 * Http cache control headers
	 * @var string
	 */
	public $cacheControl = 'max-age=3600, public';
	
	public function preFilter($filterChain)
	{
		if($this->lastModified || $this->lastModifiedExpression)
		{
			if($this->lastModifiedExpression)
			{
				$value=$this->evaluateExpression($this->lastModifiedExpression);
				if(($lastModified=strtotime($value))===false)
					throw new CException("HttpCacheFilter.lastModifiedExpression evaluated to '{$value}' which could not be understood by strtotime()");
			}
			else
			{
				if(($lastModified=strtotime($this->lastModified))===false)
					throw new CException("HttpCacheFilter.lastModified contained '{$this->lastModified}' which could not be understood by strottime()");
			}
			
			if(key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])>=$lastModified)
			{
				$this->send304();
				return false;
			}
			
			header('Last-Modified: '.date('r', $lastModified));
		}
		elseif($this->etagSeed || $this->etagSeedExpression)
		{
			if($this->etagSeedExpression)<commit_msg>Only cache requests issued via GET and HEAD (as per RFC)<commit_after><?php
class CHttpCacheFilter extends CFilter
{
	/**
	 * Timestamp for the last modification date. Must be a string parsable by {@link http://php.net/strtotime strtotime()}.
	 * @var string
	 */
	public $lastModified;

	/**
	 * Expression for the last modification date. If set, this takes precedence over {@link lastModified}.
	 * @var string|callback
	 */
	public $lastModifiedExpression;
	/**
	 * Seed for the ETag. Can be anything that passes through {@link http://php.net/serialize serialize()}.
	 * @var mixed
	 */
	public $etagSeed;
	
	/**
	 * Expression for the ETag seed. If set, this takes precedence over {@link etag}. 
	 * @var string|callback
	 */
	public $etagSeedExpression;

	/**
	 * Http cache control headers
	 * @var string
	 */
	public $cacheControl = 'max-age=3600, public';
	
	public function preFilter($filterChain)
	{
		// Only cache GET and HEAD requests
		if(!in_array(Yii::app()->getRequest()->getRequestType(), array('GET', 'HEAD')))
			return true;
		
		if($this->lastModified || $this->lastModifiedExpression)
		{
			if($this->lastModifiedExpression)
			{
				$value=$this->evaluateExpression($this->lastModifiedExpression);
				if(($lastModified=strtotime($value))===false)
					throw new CException("HttpCacheFilter.lastModifiedExpression evaluated to '{$value}' which could not be understood by strtotime()");
			}
			else
			{
				if(($lastModified=strtotime($this->lastModified))===false)
					throw new CException("HttpCacheFilter.lastModified contained '{$this->lastModified}' which could not be understood by strottime()");
			}
			
			if(key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])>=$lastModified)
			{
				$this->send304();
				return false;
			}
			
			header('Last-Modified: '.date('r', $lastModified));
		}
		elseif($this->etagSeed || $this->etagSeedExpression)
		{
			if($this->etagSeedExpression)
{'fraction_non_alphanumeric': 0.14110101549973275, 'fraction_numerical': 0.0037413148049171567, 'mean_word_length': 4.234965034965035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3301647', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1114, 'n_words': 286}