當前位置: 首頁>>代碼示例>>Java>>正文


Java Response.getBody方法代碼示例

本文整理匯總了Java中retrofit.client.Response.getBody方法的典型用法代碼示例。如果您正苦於以下問題:Java Response.getBody方法的具體用法?Java Response.getBody怎麽用?Java Response.getBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在retrofit.client.Response的用法示例。


在下文中一共展示了Response.getBody方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: httpError

import retrofit.client.Response; //導入方法依賴的package包/類
private static void httpError(int expectedStatus, Response response) throws CommandException {
    if (null == response) {
        throw new IllegalArgumentException("Response was null");
    }

    // obtain response body
    String body = null;

    if (null != response.getBody()) {
        try (InputStream errStream = response.getBody().in()) {
            body = CharStreams.toString(new InputStreamReader(errStream));
        } catch (IOException ignored) {
        }
    }

    throw new CommandException("HTTP " + response.getStatus() + " "
            + response.getReason() + " but expected " + expectedStatus + ":\n" + body);
}
 
開發者ID:apiman,項目名稱:apiman-cli,代碼行數:19,代碼來源:ManagementApiUtil.java

示例2: responseNoContentType

import retrofit.client.Response; //導入方法依賴的package包/類
@Test public void responseNoContentType() throws IOException {
  okhttp3.Response okResponse = new okhttp3.Response.Builder()
      .code(200).message("OK")
      .body(new TestResponseBody("hello", null))
      .addHeader("foo", "bar")
      .addHeader("kit", "kat")
      .protocol(Protocol.HTTP_1_1)
      .request(new okhttp3.Request.Builder()
          .url(HOST + "/foo/bar/")
          .get()
          .build())
      .build();
  Response response = Ok3Client.parseResponse(okResponse);

  assertThat(response.getUrl()).isEqualTo(HOST + "/foo/bar/");
  assertThat(response.getStatus()).isEqualTo(200);
  assertThat(response.getReason()).isEqualTo("OK");
  assertThat(response.getHeaders()) //
      .containsExactly(new Header("foo", "bar"), new Header("kit", "kat"));
  TypedInput responseBody = response.getBody();
  assertThat(responseBody.mimeType()).isNull();
  assertThat(buffer(source(responseBody.in())).readUtf8()).isEqualTo("hello");
}
 
開發者ID:JakeWharton,項目名稱:retrofit1-okhttp3-client,代碼行數:24,代碼來源:Ok3ClientTest.java

示例3: checkFollowingRes

import retrofit.client.Response; //導入方法依賴的package包/類
private void checkFollowingRes(Response res) {
    stopMenuLoading();
    if (res.getStatus() == 204) {
        swapFollowStatus();
    }
    TypedInput body = res.getBody();
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:8,代碼來源:TeamFragment.java


注:本文中的retrofit.client.Response.getBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。