public function setMetadata($key, $value)
	{
		// The key and value should be encoded.
		$key = urlencode($key);
		$value = urlencode($value);

		if (count($this->metadataHeaders) < self::MAX_METADATA_HEADERS) {
			if (strlen($key) <= self::MAX_METADATA_KEY) {
				if (strlen($value) <= self::MAX_METADATA_VALUE) {
					$this->metadataHeaders['X-Container-Meta-' . $key] = $value;
				} else {
					throw new BadMetadataException(
						"Only " . self::MAX_METADATA_VALUE
						. " characters allowed for the metadata header value!");
				}
			} else {
				throw new BadMetadataException(
					"Only " . self::MAX_METADATA_KEY
					. " characters allowed for the metadata header key!");
			}
		} else {
			throw new BadMetadataException(
				"Only " . self::MAX_METADATA_HEADERS . " metadata headers allowed!");
		}
	}