Package org.ice.http

Examples of org.ice.http.HttpResponse


      request.setCharacterEncoding("UTF-8");
    } catch(Exception ex) {
      LogUtils.log(Level.WARNING, "Cannot set character encoding to UTF-8");
    }
    HttpRequest httpRequest = requestParser.parseRequest(new HttpRequest(request));
    HttpResponse httpResponse = new HttpResponse(response);
   
    Exception exception = null;
    try {
      boolean found = false;
      for(IRouter router: routers)  {
        IModule module = router.route(httpRequest);
        if (module != null)  {
          found = true;
          exception = dispatchModule(module, httpRequest, httpResponse, httpRequest.getTaskName());
          break;
        }
      }
      if (!found)
        throw new NotFoundException("No routers match for request: "+request.getRequestURL().toString());
    } catch (IceException ex)  {
      httpResponse.setException(ex);
      httpResponse.setStatus(ex.status);
      exception = ex;
    }
   
    if (Config.get("errorHandler") != null && exception != null)  {
      Class<? extends IErrorHandler> c = (Class<? extends IErrorHandler>) Config.get("errorHandler").getClass();
      try {
        IErrorHandler handler = (IErrorHandler) c.newInstance();
        handler.setException(exception);
        httpResponse.clearContent();
        dispatchModule(handler, httpRequest, httpResponse, "error");
      } catch (Exception ex)  {
        httpResponse.setStatus(500);
        httpResponse.setException(ex);
      }
    }
   
    httpResponse.sendResponse();
    httpResponse = null;
  }
View Full Code Here

TOP

Related Classes of org.ice.http.HttpResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.