当前位置: 首页>>代码示例>>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;未经允许,请勿转载。