private function encodeQuery($query, $arg_separator = '&')
	{
		if ( ! empty($query) && strpos($query, '?') === 0)
			$query = substr($query, 1);

		$parts = explode($arg_separator, $query);
		foreach ($parts as $index => $part)
		{
			list($key, $value) = $this->splitQueryValue($part);
			if ($value === null)
			{
				$parts[$index] = $this->encodeQueryOrFragment($key);
				continue;
			}
			$parts[$index] = sprintf(
						'%s=%s',
						$this->encodeQueryOrFragment($key),
						$this->encodeQueryOrFragment($value)
					);
		}

		return implode($arg_separator, $parts);
	}