@Override public void failure(final Throwable error) { try { if (!response.isCommitted()) { try { if (configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(INTERNAL_SERVER_ERROR, "Request failed."); } else { response.sendError(INTERNAL_SERVER_ERROR, "Request failed."); } } catch (final IllegalStateException ex) { // a race condition externally committing the response can still occur... LOGGER.log(Level.FINER, "Unable to reset failed response.", ex); } catch (final IOException ex) { throw new ContainerException(LocalizationMessages.EXCEPTION_SENDING_ERROR_RESPONSE(INTERNAL_SERVER_ERROR, "Request failed."), ex); } } } finally { LOGGER.log(Level.FINEST, "failure(...) called"); commit(); rethrow(error); } }
@Override public void sendError(int sc) throws IOException { sendError(sc, null); }
@Override public void sendError(int sc) throws IOException { sendError(sc, null); }
@Override public void sendError(int sc) throws IOException { sendError(sc, null); }
@Override public void sendError(int sc) throws IOException { sendError(sc, null); }
response.sendError(HttpStatus.FORBIDDEN_403,"!Secure");
@Override public void sendError(int sc) throws IOException { if (sc == 102) sendProcessing(); else sendError(sc, null); }
@Override public void sendError(int sc) throws IOException { if (sc == 102) sendProcessing(); else sendError(sc, null); }
public void sendError(int sc) throws IOException { if (sc==102) sendProcessing(); else sendError(sc,null); }
public void sendError(int sc) throws IOException { switch (sc) { case -1: _connection.getEndPoint().close(); break; case 102: sendProcessing(); break; default: sendError(sc,null); break; } }
public void sendError(int sc) throws IOException { switch (sc) { case -1: _connection.getEndPoint().close(); break; case 102: sendProcessing(); break; default: sendError(sc,null); break; } }
protected void sendError(int code, String reason) { try { _response.sendError(code, reason); } catch (Throwable x) { if (LOG.isDebugEnabled()) LOG.debug("Could not send error " + code + " " + reason, x); } finally { _state.errorComplete(); } }
public void sendError(int sc) throws IOException { switch (sc) { case -1: _connection.getEndPoint().close(); break; case 102: sendProcessing(); break; default: sendError(sc,null); break; } }
public void sendError(int sc) throws IOException { switch (sc) { case -1: _connection.getEndPoint().close(); break; case 102: sendProcessing(); break; default: sendError(sc,null); break; } }
private static String API_PACKAGE = "package where TestRESTService class"; public static final URI BASE_URI = UriBuilder .fromUri("http://localhost/") .port(8000) .build(); private static HttpServer initServer() throws IOException { System.out.println("Starting grizzly... " + BASE_URI); HttpServer httpServer = GrizzlyServerFactory.createHttpServer(BASE_URI, new HttpHandler() { @Override public void service(Request rqst, Response rspns) throws Exception { rspns.sendError(404); } }); // Initialize and register Jersey Servlet WebappContext context = new WebappContext("GrizzlyContext", "/"); ServletRegistration registration = context.addServlet( ServletContainer.class.getName(), ServletContainer.class); registration.setInitParameter(ServletContainer.RESOURCE_CONFIG_CLASS, PackagesResourceConfig.class.getName()); registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, API_PACKAGE); registration.addMapping("/*"); context.deploy(httpServer); return httpServer; }
protected void handleOptions(Request request,Response response) throws IOException { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); request.setHandled(true); response.setStatus(200); response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS"); response.setContentLength(0); response.complete(); }
protected void handleOptions(Request request,Response response) throws IOException { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); request.setHandled(true); response.setStatus(200); response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS"); response.setContentLength(0); response.complete(); }
public void handle(HttpChannel connection) throws IOException, ServletException { final String target=connection.getRequest().getPathInfo(); final Request request=connection.getRequest(); final Response response=connection.getResponse(); if (LOG.isDebugEnabled()) LOG.debug("{} on {}{}{} {} {}{}{}", request.getDispatcherType(), connection, System.lineSeparator(), request.getMethod(), target, request.getProtocol(), System.lineSeparator(), request.getHttpFields()); if (HttpMethod.OPTIONS.is(request.getMethod()) || "*".equals(target)) { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); handleOptions(request,response); if (!request.isHandled()) handle(target, request, request, response); } else handle(target, request, request, response); if (LOG.isDebugEnabled()) LOG.debug("RESPONSE for {} h={}{}{} {}{}{}", target, request.isHandled(), System.lineSeparator(), response.getStatus(), response.getReason(), System.lineSeparator(), response.getHttpFields()); }
public void handle(HttpChannel<?> connection) throws IOException, ServletException { final String target=connection.getRequest().getPathInfo(); final Request request=connection.getRequest(); final Response response=connection.getResponse(); if (LOG.isDebugEnabled()) LOG.debug(request.getDispatcherType()+" "+request.getMethod()+" "+target+" on "+connection); if (HttpMethod.OPTIONS.is(request.getMethod()) || "*".equals(target)) { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); handleOptions(request,response); if (!request.isHandled()) handle(target, request, request, response); } else handle(target, request, request, response); if (LOG.isDebugEnabled()) LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()+" handled="+request.isHandled()); }
public void handle(HttpChannel channel) throws IOException, ServletException { final String target=channel.getRequest().getPathInfo(); final Request request=channel.getRequest(); final Response response=channel.getResponse(); if (LOG.isDebugEnabled()) LOG.debug("{} {} {} on {}", request.getDispatcherType(), request.getMethod(), target, channel); if (HttpMethod.OPTIONS.is(request.getMethod()) || "*".equals(target)) { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); handleOptions(request,response); if (!request.isHandled()) handle(target, request, request, response); } else handle(target, request, request, response); if (LOG.isDebugEnabled()) LOG.debug("handled={} async={} committed={} on {}", request.isHandled(),request.isAsyncStarted(),response.isCommitted(),channel); }