public static void drainClientResponse(final Response response) { if (response != null) { BufferedInputStream bis = null; try { bis = new BufferedInputStream(response.readEntity(InputStream.class)); IOUtils.copy(bis, new NullOutputStream()); } catch (final IOException ioe) { logger.info("Failed clearing out non-client response buffer due to: " + ioe, ioe); } finally { IOUtils.closeQuietly(bis); } } } }
@Override public void process(final InputStream in) throws IOException { try (final DigestOutputStream digestOut = new DigestOutputStream(new NullOutputStream(), digest)) { StreamUtils.copy(in, digestOut); final byte[] hash = digest.digest(); final StringBuilder strb = new StringBuilder(hash.length * 2); for (int i = 0; i < hash.length; i++) { strb.append(Integer.toHexString((hash[i] & 0xFF) | 0x100), 1, 3); } hashValueHolder.set(strb.toString()); } } });
private void drainResponse(final NodeResponse response) { if (response.hasThrowable()) { return; } try { ((StreamingOutput) response.getResponse().getEntity()).write(new NullOutputStream()); } catch (final IOException ioe) { logger.info("Failed clearing out non-client response buffer from " + response.getNodeId() + " due to: " + ioe, ioe); } } }
@Override public void run() { try { final int port = ((HandleHttpRequest) runner.getProcessor()).getPort(); final HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:" + port + "/my/path?query=true&value1=value1&value2=&value3&value4=apple=orange").openConnection(); connection.setDoOutput(false); connection.setRequestMethod("GET"); connection.setRequestProperty("header1", "value1"); connection.setRequestProperty("header2", ""); connection.setRequestProperty("header3", "apple=orange"); connection.setConnectTimeout(3000); connection.setReadTimeout(3000); StreamUtils.copy(connection.getInputStream(), new NullOutputStream()); } catch (final Throwable t) { t.printStackTrace(); Assert.fail(t.toString()); } } });
@Override public void run() { HttpURLConnection connection = null; try { final int port = ((HandleHttpRequest) runner.getProcessor()).getPort(); connection = (HttpURLConnection) new URL("http://localhost:" + port + "/my/path?query=true&value1=value1&value2=&value3&value4=apple=orange").openConnection(); connection.setDoOutput(false); connection.setRequestMethod("GET"); connection.setRequestProperty("header1", "value1"); connection.setRequestProperty("header2", ""); connection.setRequestProperty("header3", "apple=orange"); connection.setConnectTimeout(20000); connection.setReadTimeout(20000); StreamUtils.copy(connection.getInputStream(), new NullOutputStream()); } catch (final Throwable t) { t.printStackTrace(); if(connection != null ) { try { responseCode[0] = connection.getResponseCode(); } catch (IOException e) { responseCode[0] = -1; } } else { responseCode[0] = -2; } } } });
StreamUtils.copy(in, new NullOutputStream(), states.get(filePath).getState().getPosition()); } catch (final EOFException eof) {
try (final InputStream fis = new FileInputStream(firstFile); final CheckedInputStream in = new CheckedInputStream(fis, new CRC32())) { StreamUtils.copy(in, new NullOutputStream(), position);
@Override public void run() { try { final int port = ((HandleHttpRequest) runner.getProcessor()).getPort(); final HttpsURLConnection connection = (HttpsURLConnection) new URL("https://localhost:" + port + "/my/path?query=true&value1=value1&value2=&value3&value4=apple=orange").openConnection(); connection.setSSLSocketFactory(sslContext.getSocketFactory()); connection.setDoOutput(false); connection.setRequestMethod("GET"); connection.setRequestProperty("header1", "value1"); connection.setRequestProperty("header2", ""); connection.setRequestProperty("header3", "apple=orange"); connection.setConnectTimeout(3000); connection.setReadTimeout(3000); StreamUtils.copy(connection.getInputStream(), new NullOutputStream()); } catch (final Throwable t) { t.printStackTrace(); Assert.fail(t.toString()); } } });
StreamUtils.copy(in, new NullOutputStream(), position);
@Override public void process(final InputStream in) throws IOException { try (final DigestOutputStream digestOut = new DigestOutputStream(new NullOutputStream(), digest)) { StreamUtils.copy(in, digestOut); final byte[] hash = digest.digest(); final StringBuilder strb = new StringBuilder(hash.length * 2); for (int i = 0; i < hash.length; i++) { strb.append(Integer.toHexString((hash[i] & 0xFF) | 0x100), 1, 3); } hashValueHolder.set(strb.toString()); } } });
StreamUtils.copy(in, new NullOutputStream(), states.get(filePath).getState().getPosition()); } catch (final EOFException eof) {
try (final InputStream fis = new FileInputStream(firstFile); final CheckedInputStream in = new CheckedInputStream(fis, new CRC32())) { StreamUtils.copy(in, new NullOutputStream(), position);
StreamUtils.copy(in, new NullOutputStream(), position);