ClientConfigLoader { RSConfig fetch(HttpUrl url) throws IOException { final Request request = new Request.Builder() .url(url) .build(); final RSConfig config = new RSConfig(); try (final Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { throw new IOException("Unsuccessful response: " + response.message()); } String str; final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream(), StandardCharsets.UTF_8)); while ((str = in.readLine()) != null) { int idx = str.indexOf('='); if (idx == -1) { continue; } String s = str.substring(0, idx); switch (s) { case "param": str = str.substring(idx + 1); idx = str.indexOf('='); s = str.substring(0, idx); config.getAppletProperties().put(s, str.substring(idx + 1)); break; case "msg": break; default: config.getClassLoaderProperties().put(s, str.substring(idx + 1)); break; } } } return config; }    }
@Test public void testFetch() throws IOException { final RSConfig config = new ClientConfigLoader(new OkHttpClient()).fetch(server.url("/")); assertEquals("http: }