Make it robust in case connection.getResHeader() returns null.