request might get updated in the urlRewriter.rewrite, so moving it to the top will break in that case.