public class Recorder extends Object
markContentBegin() to demarc the transition between HTTP
header and body.| Modifier and Type | Field and Description |
|---|---|
protected String |
characterEncoding
recording-input (ris) content character encoding.
|
protected Charset |
charset
Charset to use for CharSequence provision.
|
protected String |
contentEncoding
recording-input (ris) entity content-encoding (eg gzip, deflate), if any
|
protected static ThreadLocal<Recorder> |
currentRecorder |
protected boolean |
inputIsChunked
whether recording-input (ris) message-body is chunked
|
protected static Logger |
logger |
protected static Set<String> |
SUPPORTED_ENCODINGS |
| Constructor and Description |
|---|
Recorder(File file,
int outBufferSize,
int inBufferSize) |
Recorder(File tempDir,
String backingFilenameBase)
Create an HttpRecorder.
|
Recorder(File tempDir,
String backingFilenameBase,
int outBufferSize,
int inBufferSize)
Create an HttpRecorder.
|
| Modifier and Type | Method and Description |
|---|---|
protected static int |
calcRecommendedCharBufferSize(RecordingInputStream inStream)
Calculate a recommended size for an in-memory decoded-character buffer
of this content.
|
void |
cleanup()
Cleanup backing files.
|
void |
close()
Close all streams.
|
void |
closeRecorders()
Close both input and output recorders.
|
void |
copyContentBodyTo(File tempFile) |
void |
endReplays() |
Charset |
getCharset() |
String |
getContentEncoding() |
ReplayCharSequence |
getContentReplayCharSequence() |
ReplayCharSequence |
getContentReplayCharSequence(Charset requestedCharset) |
InputStream |
getContentReplayInputStream()
Get a replay cued up for the 'content' (after all leading headers)
|
String |
getContentReplayPrefixString(int size)
Return a short prefix of the presumed-textual content as a String.
|
String |
getContentReplayPrefixString(int size,
Charset cs)
Return a short prefix of the presumed-textual content as a String.
|
InputStream |
getEntityReplayInputStream()
Get a raw replay of the 'entity'.
|
static Recorder |
getHttpRecorder()
Get the current threads' HttpRecorder.
|
ReplayInputStream |
getMessageBodyReplayInputStream()
Get a raw replay of the 'message-body'.
|
RecordingInputStream |
getRecordedInput()
Return the internal RecordingInputStream
|
RecordingOutputStream |
getRecordedOutput() |
ReplayCharSequence |
getReplayCharSequence()
Deprecated.
use getContentReplayCharSequence
|
ReplayInputStream |
getReplayInputStream()
Get a raw replay of all recorded data (including, for example, HTTP
protocol headers)
|
long |
getResponseContentLength() |
InputStream |
inputWrap(InputStream is)
Wrap the provided stream with the internal RecordingInputStream
open() throws an exception if RecordingInputStream is already open.
|
void |
markContentBegin()
Mark current position as the point where the HTTP headers end.
|
OutputStream |
outputWrap(OutputStream os)
Wrap the provided stream with the internal RecordingOutputStream
open() throws an exception if RecordingOutputStream is already open.
|
void |
setCharset(Charset cs) |
void |
setContentEncoding(String contentEncoding) |
static void |
setHttpRecorder(Recorder httpRecorder) |
void |
setInputIsChunked(boolean chunked) |
static Recorder |
wrapInputStreamWithHttpRecord(File dir,
String basename,
InputStream in,
String encoding)
Record the input stream for later playback by an extractor, etc.
|
protected static Logger logger
protected String characterEncoding
protected Charset charset
protected boolean inputIsChunked
protected String contentEncoding
protected static ThreadLocal<Recorder> currentRecorder
public Recorder(File tempDir, String backingFilenameBase, int outBufferSize, int inBufferSize)
tempDir - Directory into which we drop backing files for
recorded input and output.backingFilenameBase - Backing filename base to which we'll append
suffices ris for recorded input stream and
ros for recorded output stream.outBufferSize - Size of output buffer to use.inBufferSize - Size of input buffer to use.public Recorder(File file, int outBufferSize, int inBufferSize)
public Recorder(File tempDir, String backingFilenameBase)
tempDir - Directory into which we drop backing files for recorded input
and output.backingFilenameBase - Backing filename base to which we'll append suffices
ris for recorded input stream and
ros for recorded output stream.public InputStream inputWrap(InputStream is) throws IOException
is - InputStream to wrap.IOExceptionpublic OutputStream outputWrap(OutputStream os) throws IOException
os - The output stream to wrap.IOExceptionpublic void close()
public RecordingInputStream getRecordedInput()
public RecordingOutputStream getRecordedOutput()
public void markContentBegin()
public long getResponseContentLength()
public void closeRecorders()
close() closes the stream that is being recorded and the
recorder. This method explicitly closes the recorder only.public void cleanup()
public static void setHttpRecorder(Recorder httpRecorder)
public static Recorder getHttpRecorder()
public void setCharset(Charset cs)
characterEncoding - Character encoding of input recording.public Charset getCharset()
public void setInputIsChunked(boolean chunked)
characterEncoding - Character encoding of input recording.public void setContentEncoding(String contentEncoding)
contentEncoding - declared content-encoding of input recording.public String getContentEncoding()
public ReplayCharSequence getReplayCharSequence() throws IOException
IOExceptionpublic ReplayCharSequence getContentReplayCharSequence() throws IOException
ReplayCharSequence.close() when finished. However, in
heritrix, the ReplayCharSequence is closed automatically when url
processing has finished; in that context it's preferable not
to close, so that processors can reuse the same instance.IOException#endReplays()}public ReplayCharSequence getContentReplayCharSequence(Charset requestedCharset) throws IOException
characterEncoding - Encoding of recorded stream.IOExceptionprotected static int calcRecommendedCharBufferSize(RecordingInputStream inStream)
inStream - public ReplayInputStream getReplayInputStream() throws IOException
IOExceptionpublic ReplayInputStream getMessageBodyReplayInputStream() throws IOException
IOExceptionpublic InputStream getEntityReplayInputStream() throws IOException
IOExceptionpublic InputStream getContentReplayInputStream() throws IOException
IOExceptionpublic String getContentReplayPrefixString(int size)
size - max length of String to returnpublic String getContentReplayPrefixString(int size, Charset cs)
size - max length of String to returnpublic void copyContentBodyTo(File tempFile) throws IOException
tempFile - IOExceptionpublic static Recorder wrapInputStreamWithHttpRecord(File dir, String basename, InputStream in, String encoding) throws IOException
dir - Directory to write backing file to.basename - of what we're recording.in - Stream to read.encoding - Stream encoding.Recorder.IOExceptionpublic void endReplays()
Copyright © 2015 The International Internet Preservation Consortium. All Rights Reserved.