Move encode of chunked content to an extra method, this allows for inline. Related to #1812

encode of chunked content is not the most common pattern so moving it to an extra method makes it possible to inline the rest as it is a smaller method now.