add dedicated function for adding Content-Length header (bug #4795)