@Test public void testRawData() throws Exception { final String jsonPayload = "{\"name\":\"yieldnull\"}"; HttpDaemon.registerServlet("/", new HttpServlet() { @Override public HttpResponse doGet(HttpRequest request) { return null; } @Override public HttpResponse doPost(HttpRequest request) { return HttpResponse.newResponse(request.text()); } }); RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonPayload); Request request = new Request.Builder() .url(url) .post(body) .addHeader("Connection", "close") .build(); System.setProperty("http.keepAlive", "false"); Response response = new OkHttpClient().newCall(request).execute(); String json = response.body().string(); assertThat(json, is(jsonPayload)); }
public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); static void registerServlet(String urlPattern, HttpServlet servlet); static int getPort(); static HttpDaemon getSingleton(); void start(); void stop(); boolean isAlive(); boolean isStarted(); int aliveRequests(); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); static void registerServlet(String urlPattern, HttpServlet servlet); static int getPort(); static HttpDaemon getSingleton(); void start(); void stop(); boolean isAlive(); boolean isStarted(); int aliveRequests(); static int sPort; }