Throw exception when getting content length if appropriate