
xhr.multipart = function(url, obj, next) {
	var boundary = "----bo-" + Math.random()
	, req = xhr("POST", url, next)
	, data = []

	req.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary)

	Object.each(obj, function(val, key) {
		data.push(boundary)
		data.push('Content-Disposition: form-data; name="' + key + '"')
		data.push("")
		data.push(val)
	})

	data.push(boundary + "--")

	// The XMLHttpRequest specification states that
	// the data send using the .send() method is converted to unicode, and encoded as UTF-8.

	req.send(data.join("\r\n"))

	// Due to Firefox's bug 416178, it's required to use sendAsBinary() instead of send()
	// xhr.sendAsBinary(data)
}

