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

Method run

samples/guide/src/main/java/okhttp3/recipes/PostString.java:31–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29 private final OkHttpClient client = new OkHttpClient();
30
31 public void run() throws Exception {
32 String postBody = ""
33 + "Releases\n"
34 + "--------\n"
35 + "\n"
36 + " * _1.0_ May 6, 2013\n"
37 + " * _1.1_ June 15, 2013\n"
38 + " * _1.2_ August 11, 2013\n";
39
40 Request request = new Request.Builder()
41 .url("https://api.github.com/markdown/raw")
42 .post(RequestBody.create(postBody, MEDIA_TYPE_MARKDOWN))
43 .build();
44
45 try (Response response = client.newCall(request).execute()) {
46 if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
47
48 System.out.println(response.body().string());
49 }
50 }
51
52 public static void main(String... args) throws Exception {
53 new PostString().run();

Callers 1

mainMethod · 0.45

Calls 2

postMethod · 0.80
createMethod · 0.80

Tested by

no test coverage detected