Property definitions

curl $ HeaderMap :: defaultinit
# Pseudo map associating `String` to `String` for HTTP exchanges
#
# This structure differs from `Map` as each key can have multiple associations
# and the order of insertion is important to some services.
class HeaderMap
	private var array = new Array[Couple[String, String]]

	# Add a `value` associated to `key`
	fun []=(key, value: String)
	do
		array.add new Couple[String, String](key, value)
	end

	# Get a list of the keys associated to `key`
	fun [](k: String): Array[String]
	do
		var res = new Array[String]
		for c in array do if c.first == k then res.add c.second
		return res
	end

	# Iterate over all the associations in `self`
	fun iterator: MapIterator[String, String] do return new HeaderMapIterator(self)

	# Get `self` as a single string for HTTP POST
	#
	# Require: `curl.is_ok`
	private fun to_url_encoded(curl: Curl): String
	do
		assert curl.is_ok

		var lines = new Array[String]
		for k, v in self do
			if k.length == 0 then continue

			k = curl.native.escape(k)
			v = curl.native.escape(v)
			lines.add "{k}={v}"
		end
		return lines.join("&")
	end

	# Concatenate couple of 'key value' separated by 'sep' in Array
	fun join_pairs(sep: String): Array[String]
	do
		var col = new Array[String]
		for k, v in self do col.add("{k}{sep}{v}")
		return col
	end

	# Number of values in `self`
	fun length: Int do return array.length

	# Is this map empty?
	fun is_empty: Bool do return array.is_empty
end
lib/curl/curl.nit:601,1--656,3