MCPcopy
hub / github.com/square/okhttp / run

Method run

samples/guide/src/main/java/okhttp3/recipes/PostForm.java:28–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 private final OkHttpClient client = new OkHttpClient();
27
28 public void run() throws Exception {
29 RequestBody formBody = new FormBody.Builder()
30 .add("search", "Jurassic Park")
31 .build();
32 Request request = new Request.Builder()
33 .url("https://en.wikipedia.org/w/index.php")
34 .post(formBody)
35 .build();
36
37 try (Response response = client.newCall(request).execute()) {
38 if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
39
40 System.out.println(response.body().string());
41 }
42 }
43
44 public static void main(String... args) throws Exception {
45 new PostForm().run();

Callers 1

mainMethod · 0.45

Calls 1

postMethod · 0.80

Tested by

no test coverage detected