retrieve the content length into a local variable, as it's fetched twice on a valid condition.