@Override public void onResponse(Call call, Response response) throws IOException { response.close(); } }
/** * Equivalent to closing contentReader or contentStream. */ @Override public void close() { okResponse.close(); } }
@Override public void onResponse(Call call, Response response) throws IOException { response.close(); } });
static void closeQuietly(Response response) { try { if (response != null) { response.close(); } } catch (Exception ignore) { // ignore } }
@Override public void onResponse(Call call, Response response) { log.debug("Submitted loot"); response.close(); } });
@Override public void onResponse(Call call, Response response) { log.debug("Deleted loot"); response.close(); } });
@Override public void onResponse(Call call, Response response) { response.close(); logger.debug("Synchronized configuration value '{}' to '{}'", key, value); } });
@Override public void onResponse(Call call, Response response) { response.close(); logger.debug("Submitted xp track for {}", username); } });
@Override public void onResponse(Call call, Response response) { response.close(); logger.debug("Unset configuration value '{}'", key); } });
@Override public void onResponse(Call call, Response response) { response.close(); logger.debug("Submitted examine info for {} {}: {}", type, id, text); } });
@Override public Bitmap convertResponse(Response response) throws Throwable { Bitmap bitmap = convert.convertResponse(response); response.close(); return bitmap; } }
@Override public String convertResponse(Response response) throws Throwable { String s = convert.convertResponse(response); response.close(); return s; } }
@Override public File convertResponse(Response response) throws Throwable { File file = convert.convertResponse(response); response.close(); return file; } }
@Override @SneakyThrows public void postStream(InputStream body) { Request request = requestBuilder .post(toRequestBody(body, null)) .build(); execute(request).close(); }
@Override @SneakyThrows public void delete() { Request request = requestBuilder .delete() .build(); execute(request).close(); }
/** * Gets called when an http request error takes place. This is the case when the returned http status code doesn't * lie in the range 200 (inclusive) and 300 (exclusive). */ public void onHttpError(@NotNull ApolloHttpException e) { onFailure(e); Response response = e.rawResponse(); if (response != null) { response.close(); } }
private List<InetAddress> readResponse(String hostname, Response response) throws Exception { if (response.cacheResponse() == null && response.protocol() != Protocol.HTTP_2) { Platform.get().log(Platform.WARN, "Incorrect protocol: " + response.protocol(), null); } try { if (!response.isSuccessful()) { throw new IOException("response: " + response.code() + " " + response.message()); } ResponseBody body = response.body(); if (body.contentLength() > MAX_RESPONSE_SIZE) { throw new IOException("response size exceeds limit (" + MAX_RESPONSE_SIZE + " bytes): " + body.contentLength() + " bytes"); } ByteString responseBytes = body.source().readByteString(); return DnsRecordCodec.decodeAnswers(hostname, responseBytes); } finally { response.close(); } }
void delete(UUID uuid) throws IOException { HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder() .addPathSegment("session") .addQueryParameter("session", uuid.toString()) .build(); Request request = new Request.Builder() .delete() .url(url) .build(); RuneLiteAPI.CLIENT.newCall(request).execute().close(); } }
public void processResponse(Response response) { try { if (!response.isSuccessful()) { listener.onFailure(this, null, response); return; } ResponseBody body = response.body(); //noinspection ConstantConditions main body is never null MediaType contentType = body.contentType(); if (!isEventStream(contentType)) { listener.onFailure(this, new IllegalStateException("Invalid content-type: " + contentType), response); return; } // Replace the body with an empty one so the callbacks can't see real data. response = response.newBuilder().body(Util.EMPTY_RESPONSE).build(); ServerSentEventReader reader = new ServerSentEventReader(body.source(), this); try { listener.onOpen(this, response); while (reader.processNextEvent()) { } } catch (Exception e) { listener.onFailure(this, e, response); return; } listener.onClosed(this); } finally { response.close(); } }
@Override @SneakyThrows public void put(InputStream body, com.github.dockerjava.core.MediaType mediaType) { Request request = requestBuilder .put(toRequestBody(body, mediaType.toString())) .build(); execute(request).close(); }