Improved write methods to send more appropiate headers if no payload is available.