lithium\action\Request::_parseAccept()

protected method

Parses the HTTP_ACCEPT information the requesting client sends, and converts that data to an array for consumption by the rest of the framework.

Returns

array

All the types of content the client can accept.

Source

	protected function _parseAccept() {
		$accept = $this->env('HTTP_ACCEPT');
		$accept = ($accept && preg_match('/[a-z,-]/i', $accept)) ? explode(',', $accept) : ['text/html'];

		foreach (array_reverse($accept) as $i => $type) {
			unset($accept[$i]);
			list($type, $q) = (explode(';q=', $type, 2) + [$type, 1.0 + $i / 100]);
			$accept[$type] = ($type === '*/*') ? 0.1 : floatval($q);
		}
		arsort($accept, SORT_NUMERIC);

		if (isset($accept['application/xhtml+xml']) && $accept['application/xhtml+xml'] >= 1) {
			unset($accept['application/xml']);
		}
		$media = $this->_classes['media'];

		if (isset($this->params['type']) && ($handler = $media::type($this->params['type']))) {
			if (isset($handler['content'])) {
				$type = (array) $handler['content'];
				$accept = [current($type) => 1] + $accept;
			}
		}
		return array_keys($accept);
	}