@Test public void requestBodyShouldBeReusable() { HttpObject resource = new HttpObject("/", DSL.allowed(Method.POST)) { @Override public Response post(Request req) { System.out.print(req.show()); if (req.body().get().equals("body")) return OK(Text("We did it!")); else return BAD_REQUEST(); } }; int port = findFreePort(); HttpClient client = new ApacheCommons4xHttpClient(); HttpObjectsJettyHandler.launchServer(port, resource); Response result = client.resource("http: assertEquals(ResponseCode.OK, result.code()); }
public static Server launchServer(int port, HttpObject... objects) { try { Server s = new Server(port); s.setHandler(new HttpObjectsJettyHandler(Collections.singletonList(new GenericHeaderField("Cache-Control", "no-cache")), objects)); s.start(); return s; } catch (Exception e) { throw new RuntimeException("" + e.getMessage() + " (port = " + port + ")", e); } }
HttpObjectsJettyHandler extends org.eclipse.jetty.server.handler.AbstractHandler { public static Server launchServer(int port, HttpObject... objects) { try { Server s = new Server(port); s.setHandler(new HttpObjectsJettyHandler(Collections.singletonList(new GenericHeaderField("Cache-Control", "no-cache")), objects)); s.start(); return s; } catch (Exception e) { throw new RuntimeException("" + e.getMessage() + " (port = " + port + ")", e); } } }
HttpObjectsJettyHandler extends org.eclipse.jetty.server.handler.AbstractHandler { public static Server launchServer(int port, HttpObject... objects) { try { Server s = new Server(port); s.setHandler(new HttpObjectsJettyHandler(Collections.singletonList(new GenericHeaderField("Cache-Control", "no-cache")), objects)); s.start(); return s; } catch (Exception e) { throw new RuntimeException("" + e.getMessage() + " (port = " + port + ")", e); } } HttpObjectsJettyHandler(HttpObject... objects);  HttpObjectsJettyHandler(List<? extends HeaderField> defaultResponseHeaders, HttpObject... objects); }
HttpObjectsJettyHandler extends org.eclipse.jetty.server.handler.AbstractHandler { public static Server launchServer(int port, HttpObject... objects) { try { Server s = new Server(port); s.setHandler(new HttpObjectsJettyHandler(Collections.singletonList(new GenericHeaderField("Cache-Control", "no-cache")), objects)); s.start(); return s; } catch (Exception e) { throw new RuntimeException("" + e.getMessage() + " (port = " + port + ")", e); } } HttpObjectsJettyHandler(HttpObject... objects);  HttpObjectsJettyHandler(List<? extends HeaderField> defaultResponseHeaders, HttpObject... objects); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); static Server launchServer(int port, HttpObject... objects); static JettyServerContract launchServerContract(int port, HttpObject... objects); }
HttpObjectsJettyHandler extends org.eclipse.jetty.server.handler.AbstractHandler { public static Server launchServer(int port, HttpObject... objects) { try { Server s = new Server(port); s.setHandler(new HttpObjectsJettyHandler(Collections.singletonList(new GenericHeaderField("Cache-Control", "no-cache")), objects)); s.start(); return s; } catch (Exception e) { throw new RuntimeException("" + e.getMessage() + " (port = " + port + ")", e); } } HttpObjectsJettyHandler(HttpObject... objects);  HttpObjectsJettyHandler(List<? extends HeaderField> defaultResponseHeaders, HttpObject... objects); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); static Server launchServer(int port, HttpObject... objects); static JettyServerContract launchServerContract(int port, HttpObject... objects);  }