StatusCodeCaptureWrapper.java

  1. /*  This file is part of Openrouteservice.
  2.  *
  3.  *  Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
  4.  *  GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
  5.  *  of the License, or (at your option) any later version.

  6.  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  7.  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8.  *  See the GNU Lesser General Public License for more details.

  9.  *  You should have received a copy of the GNU Lesser General Public License along with this library;
  10.  *  if not, see <https://www.gnu.org/licenses/>.
  11.  */
  12. package org.heigit.ors.api.servlet.requests;

  13. import jakarta.servlet.http.HttpServletResponse;
  14. import jakarta.servlet.http.HttpServletResponseWrapper;

  15. /**
  16.  * Suppresses calls to sendError() and uses setStatus() instead to avoid sending a html error page.
  17.  * See {@link jakarta.servlet.http.HttpServletResponse#sendError(int)}
  18.  */
  19. public class StatusCodeCaptureWrapper extends HttpServletResponseWrapper {

  20.     public StatusCodeCaptureWrapper(HttpServletResponse response) {
  21.         super(response);
  22.     }

  23.     @Override
  24.     public void sendError(int sc) {
  25.         super.setStatus(sc);
  26.     }

  27.     @Override
  28.     public void sendError(int sc, String msg) {
  29.         super.setStatus(sc);
  30.     }
  31. }