/** Copies a resource into a file. A temporary file is created and then atomically renamed to the destination file. This prevents leaving a partial file in case of a crash. @param recis the RecordingInputStream that recorded the contents of the resource @param dest the destination file @throws IOException on I/O error @throws IOException if the file rename fails */ private void writeToPath(RecordingInputStream recis, File dest) throws IOException { File tf = new File (dest.getPath() + "N"); ReplayInputStream replayis = null; FileOutputStream fos = null; try { replayis = recis.getMessageBodyReplayInputStream(); fos = new FileOutputStream(tf); replayis.readFullyTo(fos); } finally { IOUtils.closeQuietly(replayis); IOUtils.closeQuietly(fos); } if (!tf.renameTo(dest)) { throw new IOException("Can not rename " + tf.getAbsolutePath() + " to " + dest.getAbsolutePath()); } }
/** * Get a raw replay of the 'message-body'. For the common case of * HTTP, this is the raw, possibly chunked-transfer-encoded message * contents not including the leading headers. * * @return A replay input stream. * @throws IOException */ public ReplayInputStream getMessageBodyReplayInputStream() throws IOException { return getRecordedInput().getMessageBodyReplayInputStream(); }
/** * Get a raw replay of the 'message-body'. For the common case of * HTTP, this is the raw, possibly chunked-transfer-encoded message * contents not including the leading headers. * * @return A replay input stream. * @throws IOException */ public ReplayInputStream getMessageBodyReplayInputStream() throws IOException { return getRecordedInput().getMessageBodyReplayInputStream(); }
/** * Get a raw replay of the 'message-body'. For the common case of * HTTP, this is the raw, possibly chunked-transfer-encoded message * contents not including the leading headers. * * @return A replay input stream. * @throws IOException */ public ReplayInputStream getMessageBodyReplayInputStream() throws IOException { return getRecordedInput().getMessageBodyReplayInputStream(); }
/** * Get a raw replay of the 'entity'. For the common case of * HTTP, this is the message-body after any (usually-unnecessary) * transfer-decoding but before any content-encoding (eg gzip) decoding * * @return A replay input stream. * @throws IOException */ public InputStream getEntityReplayInputStream() throws IOException { if(inputIsChunked) { return new ChunkedInputStream(getRecordedInput().getMessageBodyReplayInputStream()); } else { return getRecordedInput().getMessageBodyReplayInputStream(); } }
/** * Get a raw replay of the 'entity'. For the common case of * HTTP, this is the message-body after any (usually-unnecessary) * transfer-decoding but before any content-encoding (eg gzip) decoding * * @return A replay input stream. * @throws IOException */ public InputStream getEntityReplayInputStream() throws IOException { if(inputIsChunked) { return new ChunkedInputStream(getRecordedInput().getMessageBodyReplayInputStream()); } else { return getRecordedInput().getMessageBodyReplayInputStream(); } }
/** * Get a raw replay of the 'entity'. For the common case of * HTTP, this is the message-body after any (usually-unnecessary) * transfer-decoding but before any content-encoding (eg gzip) decoding * * @return A replay input stream. * @throws IOException */ public InputStream getEntityReplayInputStream() throws IOException { if(inputIsChunked) { return new ChunkedInputStream(getRecordedInput().getMessageBodyReplayInputStream()); } else { return getRecordedInput().getMessageBodyReplayInputStream(); } }
/** Copies a resource into a file. A temporary file is created and then atomically renamed to the destination file. This prevents leaving a partial file in case of a crash. @param recis the RecordingInputStream that recorded the contents of the resource @param dest the destination file @throws IOException on I/O error @throws IOException if the file rename fails */ private void writeToPath(RecordingInputStream recis, File dest) throws IOException { File tf = new File (dest.getPath() + "N"); ReplayInputStream replayis = null; FileOutputStream fos = null; try { replayis = recis.getMessageBodyReplayInputStream(); fos = new FileOutputStream(tf); replayis.readFullyTo(fos); } finally { IOUtils.closeQuietly(replayis); IOUtils.closeQuietly(fos); } if (!tf.renameTo(dest)) { throw new IOException("Can not rename " + tf.getAbsolutePath() + " to " + dest.getAbsolutePath()); } }