retrofit.client.Response.getReason()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中retrofit.client.Response.getReason方法的一些代码示例,展示了Response.getReason的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getReason方法的具体详情如下:
包路径:retrofit.client.Response
类名称:Response
方法名:getReason

Response.getReason介绍

[英]Status line reason phrase.
[中]状态线原因短语。

代码示例

代码示例来源:origin: com.squareup.retrofit/retrofit

public static RetrofitError httpError(String url, Response response, Converter converter,
  Type successType) {
 String message = response.getStatus() + " " + response.getReason();
 return new RetrofitError(message, url, response, converter, successType, Kind.HTTP, null);
}

代码示例来源:origin: com.github.heuermh.ensemblrestclient/ensembl-rest-client

/**
 * Return the status line reason phrase.
 *
 * @return the status line reason phrase, or <code>""</code> if the error response is null
 */
public String getReason()
{
  return retrofitError.getResponse() == null ? "" : retrofitError.getResponse().getReason();
}

代码示例来源:origin: com.squareup.retrofit/retrofit

static Response replaceResponseBody(Response response, TypedInput body) {
 return new Response(response.getUrl(), response.getStatus(), response.getReason(),
   response.getHeaders(), body);
}

代码示例来源:origin: io.divide/client-java

/**
 *
 * @param type class type contained within response
 * @param response Retrofit response to be converted to type.
 * @return ServerResponse containing object contained within retrofit response
 */
public static <T> ServerResponse<T> from(Class<T> type,Response response){
  logger.debug("from("+type.getName()+"): " + response.getStatus());
  ServerResponse<T> o = null;
  try {
    o = new ServerResponse<T>(convertBody(type,response),Status.valueOf(response.getStatus()),response.getReason());
  } catch (Exception e) {
    e.printStackTrace();
  }
  return o;
}

代码示例来源:origin: graylog-labs/collector

private void register(final boolean legacy) {
  try {
    if (legacy) {
      collectorRegistrationService.legacyRegister(this.collectorId, this.collectorRegistrationRequest);
    } else {
      collectorRegistrationService.register(this.collectorId, this.collectorRegistrationRequest);
    }
  } catch (RetrofitError e) {
    final Response response = e.getResponse();
    if (response != null) {
      if (!legacy && response.getStatus() == 404) {
        // Try again with the Graylog 1.x URL if we didn't try yet.
        register(true);
      } else {
        LOG.warn("Unable to send heartbeat to Graylog server, result was: {} - {}", response.getStatus(), response.getReason());
      }
    } else {
      final String message;
      if (e.getCause() != null) {
        message = e.getCause().getClass().getSimpleName() + ": " + e.getCause().getMessage();
      } else {
        message = e.getClass().getSimpleName() + ": " + e.getMessage();
      }
      LOG.warn("Unable to send heartbeat to Graylog server: {}", message);
    }
  }
}

相关文章