implementing multipart writing for breaking up large messages
pulled from weisjohn