Class WarcRecorder
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpFiltersSource
WarcRecorder recorder = WarcRecorder.builder(Path.of("warcs")).build();
MicroProxy.bootstrap().withFiltersSource(recorder).start();
...
recorder.close();
Each exchange with a server becomes a request record and a response record
linked by WARC-Concurrent-To, with block and payload digests, the target URI (
https:// inside intercepted sessions) and the server's IP address when known. Bodies are
captured as they stream past, without buffering the exchange: in memory, or in a temporary file
once large, up to WarcRecorder.Builder.maxBodySize (beyond that the record is marked
WARC-Truncated: length). Messages are recorded as exchanged except that chunked transfer coding
is removed and Content-Length states the recorded body length; content codings such as
gzip are kept.
Only traffic that reaches a server is recorded: responses from a cache or a filter are not,
and neither are tunnelled (CONNECT, not intercepted) bytes. Install the recorder first
among the filters to record messages before other filters change them.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic WarcRecorder.BuilderStarts a builder with the default settings.voidclose()Finishes the current WARC file.longReturns exchanges that could not be written.filterRequest(HttpRequest originalRequest, FlowContext flowContext) Returns the filters for a request, ornullto proxy it unfiltered.longReturns exchanges recorded so far.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microproxy.HttpFiltersSource
getMaximumRequestBufferSizeInBytes, getMaximumResponseBufferSizeInBytes
-
Method Details
-
builder
Starts a builder with the default settings.- Parameters:
dir- the directory in which to create WARC files- Returns:
- a new builder with default settings
-
recordedExchanges
public long recordedExchanges()Returns exchanges recorded so far.- Returns:
- exchanges recorded so far
-
failedExchanges
public long failedExchanges()Returns exchanges that could not be written.- Returns:
- exchanges that could not be written
-
filterRequest
Description copied from interface:HttpFiltersSourceReturns the filters for a request, ornullto proxy it unfiltered.- Specified by:
filterRequestin interfaceHttpFiltersSource- Parameters:
originalRequest- a copy of the request as received from the clientflowContext- the client connection the request arrived on- Returns:
- the per-request filters, or
nullto leave the request unfiltered
-
close
Finishes the current WARC file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-