コード例 #1
0
  Response execute(Request request, boolean checkStatus) throws IOException {
    Response response = network.execute(request);

    if (checkStatus && response.hasFailed()) {
      // check error first
      String msg = parseContent(response.body(), "error");
      if (!StringUtils.hasText(msg)) {
        msg =
            String.format(
                "[%s] on [%s] failed; server[%s] returned [%s:%s]",
                request.method().name(),
                request.path(),
                response.uri(),
                response.status(),
                response.statusDescription());
      }

      throw new IllegalStateException(msg);
    }

    return response;
  }
コード例 #2
0
 @Override
 public void close() {
   network.close();
 }