List of usage examples for javax.servlet.http HttpServletRequest isAsyncSupported
public boolean isAsyncSupported();
From source file:com.kurento.kmf.content.internal.base.AbstractContentHandlerServlet.java
@Override protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { getLogger().info("POST request received: " + req.getRequestURI()); if (!req.isAsyncSupported()) { // Async context could not be created. It is not necessary to // complete it. Just send error message to ServletUtils.sendHttpError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "AsyncContext could not be started. The application should add \"asyncSupported = true\" in all " + this.getClass().getName() + " instances and in all filters in the associated chain"); return;//from w w w .j a v a2 s . c om } if (handler == null) { ServletUtils.sendHttpError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, handler.getClass().getSimpleName() + " is null. This error means that you " + "need to provide a valid implementation of interface " + handler.getClass().getSimpleName()); return; } String contentId = req.getPathInfo(); if (contentId != null) { contentId = contentId.substring(1); } AsyncContext asyncCtx = req.startAsync(); // Add listener for managing error conditions asyncCtx.addListener(new ContentAsyncListener()); if (useControlProtocol) { doRequest4JsonControlProtocol(asyncCtx, contentId, resp); } else { // TODO: we should check that the content type correspond to // the ones we support. We should avoid receiving application/json // here and send a coherent error message in that case because this // case corresponds to using incorrectly annotations on handlers doRequest4SimpleHttpProtocol(asyncCtx, contentId, resp); } }
From source file:com.kurento.kmf.content.internal.base.AbstractContentHandlerServlet.java
@Override protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (useControlProtocol) { ServletUtils.sendHttpError(req, resp, HttpServletResponse.SC_NOT_IMPLEMENTED, "Only POST request are supported for this service. You can enable GET requests " + " by setting useControlProtocol to false on the appropriate handler annotation"); return;// ww w . ja v a 2 s . c o m } getLogger().info("GET request received: " + req.getRequestURI()); if (!req.isAsyncSupported()) { // Async context could not be created. It is not necessary to // complete it. Just send error message to ServletUtils.sendHttpError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "AsyncContext could not be started. The application should add \"asyncSupported = true\" in all " + this.getClass().getName() + " instances and in all filters in the associated chain"); return; } if (handler == null) { ServletUtils.sendHttpError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, handler.getClass().getSimpleName() + " is null. This error means that you " + "need to provide a valid implementation of interface " + handler.getClass().getSimpleName()); return; } String contentId = req.getPathInfo(); if (contentId != null) { contentId = contentId.substring(1); } AsyncContext asyncCtx = req.startAsync(); // Add listener for managing error conditions asyncCtx.addListener(new ContentAsyncListener()); doRequest4SimpleHttpProtocol(asyncCtx, contentId, resp); }