Class HeaderedArchiveRecord
java.lang.Object
java.io.InputStream
org.archive.io.ArchiveRecord
org.archive.io.HeaderedArchiveRecord
- All Implemented Interfaces:
Closeable,AutoCloseable
An ArchiveRecord whose content has a preamble of RFC822-like headers: e.g.
The ArchiveRecord is a http response that leads off with http response
headers. Use this ArchiveRecord Decorator to get at the content headers and
the header/content demarcation.
- Author:
- stack, Olaf Freyer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
Fields inherited from class org.archive.io.ArchiveRecord
digest, eor, header, in, MIN_HTTP_HEADER_LENGTH, position, strict -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintThis available is not the stream's available.voidclose()Calling close on a record skips us past this record to the next record in the stream.voiddump()Writes output on STDOUT.voiddump(OutputStream os) Writes output on passedos.voidvoiddumpHttpHeader(PrintStream stream) intprotected Stringprotected Stringprotected Stringlongintprotected StringbooleanIs it likely that this record contains headers?protected voidprotected voidincrementPosition(long incr) protected booleanisEor()booleanisStrict()booleanprotected Stringstatic intparseStatusCode(String statusLine) intread()intread(byte[] b, int offset, int length) protected voidsetEor(boolean eor) protected voidsetHeader(ArchiveRecordHeader header) voidsetStrict(boolean strict) protected voidskip()Skip over this records content.longskip(long n) voidSkip over the the content headers if present.Methods inherited from class org.archive.io.ArchiveRecord
getIn, setBodyOffsetMethods inherited from class java.io.InputStream
mark, read, reset
-
Constructor Details
-
HeaderedArchiveRecord
- Throws:
IOException
-
HeaderedArchiveRecord
- Throws:
IOException
-
-
Method Details
-
skipHttpHeader
Skip over the the content headers if present. Subsequent reads will get the body.Calling this method in the midst of reading the header will make for strange results. Otherwise, safe to call at any time though before reading any of the record content is only time that it makes sense.
After calling this method, you can call
getContentHeaders()to get the read http header.- Throws:
IOException
-
dumpHttpHeader
- Throws:
IOException
-
dumpHttpHeader
- Throws:
IOException
-
parseStatusCode
-
getStatusCode
public int getStatusCode()- Returns:
- If headers are for a http response AND the headers have been read, return status code. Else return -1.
-
getContentHeadersLength
public int getContentHeadersLength()- Returns:
- Returns length of content headers or -1 if headers have not yet been read.
-
getContentHeaders
-
read
- Overrides:
readin classArchiveRecord- Returns:
- Next character in this ARCRecord's content else -1 if at end of this record.
- Throws:
IOException
-
read
- Overrides:
readin classArchiveRecord- Throws:
IOException
-
available
public int available()Description copied from class:ArchiveRecordThis available is not the stream's available. Its an available based on what the stated Archive record length is minus what we've read to date.- Overrides:
availablein classArchiveRecord- Returns:
- True if bytes remaining in record content.
-
close
Description copied from class:ArchiveRecordCalling close on a record skips us past this record to the next record in the stream. It does not actually close the stream. The underlying steam is probably being used by the next arc record.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classArchiveRecord- Throws:
IOException
-
dump
Description copied from class:ArchiveRecordWrites output on STDOUT.- Overrides:
dumpin classArchiveRecord- Throws:
IOException
-
dump
Description copied from class:ArchiveRecordWrites output on passedos.- Overrides:
dumpin classArchiveRecord- Throws:
IOException
-
getDigest4Cdx
- Overrides:
getDigest4Cdxin classArchiveRecord
-
getDigestStr
- Overrides:
getDigestStrin classArchiveRecord
-
getHeader
- Overrides:
getHeaderin classArchiveRecord- Returns:
- Header data for this record.
-
getIp4Cdx
- Overrides:
getIp4Cdxin classArchiveRecord
-
getMimetype4Cdx
- Overrides:
getMimetype4Cdxin classArchiveRecord
-
getPosition
public long getPosition()- Overrides:
getPositionin classArchiveRecord
-
getStatusCode4Cdx
- Overrides:
getStatusCode4Cdxin classArchiveRecord
-
hasContentHeaders
public boolean hasContentHeaders()Description copied from class:ArchiveRecordIs it likely that this record contains headers? This method will return true if the body is a http response that includes http response headers or the body is a http request that includes request headers, etc. Be aware that headers in content are distinct fromArchiveRecordHeader'headers'.- Overrides:
hasContentHeadersin classArchiveRecord- Returns:
- True if this Record's content has headers:
-
incrementPosition
protected void incrementPosition()- Overrides:
incrementPositionin classArchiveRecord
-
incrementPosition
protected void incrementPosition(long incr) - Overrides:
incrementPositionin classArchiveRecord
-
isEor
protected boolean isEor()- Overrides:
isEorin classArchiveRecord
-
isStrict
public boolean isStrict()- Overrides:
isStrictin classArchiveRecord- Returns:
- Returns the strict.
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classArchiveRecord
-
outputCdx
- Overrides:
outputCdxin classArchiveRecord- Throws:
IOException
-
setEor
protected void setEor(boolean eor) - Overrides:
setEorin classArchiveRecord
-
setHeader
- Overrides:
setHeaderin classArchiveRecord
-
setStrict
public void setStrict(boolean strict) - Overrides:
setStrictin classArchiveRecord- Parameters:
strict- The strict to set.
-
skip
Description copied from class:ArchiveRecordSkip over this records content.- Overrides:
skipin classArchiveRecord- Throws:
IOException
-
skip
- Overrides:
skipin classArchiveRecord- Throws:
IOException
-