public abstract class PayloadWithHeaderAbstract extends java.lang.Object implements java.io.Closeable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
bClosed
Has record been closed before.
|
protected boolean |
bIsValid
Could the header be validated.
|
protected boolean |
bNoSuchAlgorithmException
Boolean indicating no such algorithm exception under initialization.
|
Diagnostics |
diagnostics
Validation errors and warnings.
|
protected byte[] |
digest
Digest bytes.
|
protected java.lang.String |
digestAlgorithm |
protected byte[] |
header
The raw header read as bytes.
|
protected java.io.SequenceInputStream |
in_complete
Sequence of the header as a stream combined with the payload stream.
|
protected java.security.DigestInputStream |
in_digest
Automatic digesting of payload input stream.
|
protected MaxLengthRecordingInputStream |
in_flr
Stream used to ensure we don't use more than the pushback buffer on
headers and at the same time store everything read in an array.
|
protected java.io.InputStream |
in_payload
Payload stream returned to user.
|
protected ByteCountingPushBackInputStream |
in_pb
InputStream to read payload. |
protected ByteCountingPushBackInputStream |
in_pb_exposed
Pushback input stream exposed to the outside.
|
protected java.security.MessageDigest |
md
Message digest object.
|
long |
payloadLength
Object size, in bytes.
|
protected long |
totalLength
Payload length.
|
| Constructor and Description |
|---|
PayloadWithHeaderAbstract() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the this payload stream, skipping unread bytes in the process.
|
byte[] |
getDigest()
Returns the
MessageDigest used on payload stream. |
byte[] |
getHeader()
Get the raw header as bytes.
|
HeaderLine |
getHeader(java.lang.String field)
Get a header line structure or null, if no header line structure is
stored with the given header name.
|
java.util.List<HeaderLine> |
getHeaderList()
Get a
List of all the headers found during parsing. |
java.io.InputStream |
getInputStreamComplete()
Get an
InputStream containing both the header and the
payload. |
ByteCountingPushBackInputStream |
getPayloadInputStream()
Get an
InputStream containing only the payload. |
long |
getPayloadLength()
Get HTTP payload length.
|
long |
getRemaining()
Get payload remaining length.
|
long |
getTotalLength()
Get payload total length, header and payload.
|
long |
getUnavailable()
Get the number of unavailable bytes missing due to unexpected EOF.
|
protected void |
initProcess() |
boolean |
isClosed()
Check to see if the header has been closed.
|
boolean |
isValid()
Returns the result of the header validation.
|
protected abstract boolean |
readHeader(MaxLengthRecordingInputStream in,
long payloadLength)
Reads the header and updates the payloadLength field if the header is valid.
|
protected boolean bClosed
protected ByteCountingPushBackInputStream in_pb
InputStream to read payload.protected long totalLength
protected java.lang.String digestAlgorithm
protected boolean bIsValid
protected MaxLengthRecordingInputStream in_flr
protected byte[] header
protected java.security.MessageDigest md
protected byte[] digest
protected java.security.DigestInputStream in_digest
protected boolean bNoSuchAlgorithmException
protected java.io.InputStream in_payload
protected ByteCountingPushBackInputStream in_pb_exposed
protected java.io.SequenceInputStream in_complete
public long payloadLength
public Diagnostics diagnostics
public PayloadWithHeaderAbstract()
protected void initProcess() throws java.io.IOException
java.io.IOExceptionprotected abstract boolean readHeader(MaxLengthRecordingInputStream in, long payloadLength) throws java.io.IOException
in - the input stream to parse.payloadLength - the record length.java.io.IOException - I/O exception while reading headerspublic java.util.List<HeaderLine> getHeaderList()
List of all the headers found during parsing.List of HeaderLinepublic HeaderLine getHeader(java.lang.String field)
field - header nameHeaderLine structure or nullpublic boolean isValid()
public byte[] getHeader()
public byte[] getDigest()
MessageDigest used on payload stream.MessageDigest used on payload streampublic long getPayloadLength()
public long getTotalLength()
public long getUnavailable() throws java.io.IOException
0 as long as the stream is open.java.io.IOException - if errors occur calling available method on streampublic java.io.InputStream getInputStreamComplete()
InputStream containing both the header and the
payload.InputStream containing both the header and the
payload.public ByteCountingPushBackInputStream getPayloadInputStream()
InputStream containing only the payload.InputStream containing only the payload.public long getRemaining() throws java.io.IOException
java.io.IOException - if errors occur calling available method on streampublic boolean isClosed()
public void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - I/O exception in closing processCopyright © 2011–2023. All rights reserved.