using Buffer to calculate request content length
rolled version
added support for BOM characters