fix length check for res.end