Fix error on calling addHeader under certain condition.