Why not directly use request->referer() ?