| Modifier and Type | Field and Description |
|---|---|
protected AbstractBody |
body |
protected Header |
header |
protected String |
version |
| Constructor and Description |
|---|
Message() |
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(MessageObserver observer) |
boolean |
containsObserver(MessageObserver obs) |
protected void |
createBody(InputStream in) |
<T extends Message> |
createMessageSnapshot(T result) |
abstract <T extends Message> |
createSnapshot() |
void |
discardBody() |
int |
estimateHeapSize() |
AbstractBody |
getBody() |
InputStream |
getBodyAsStream()
Probably you want to use
getBodyAsStreamDecoded() instead: |
InputStream |
getBodyAsStreamDecoded()
Returns the logical body content.
|
String |
getBodyAsStringDecoded()
As this method has bad performance, it should not be used in any critical component.
|
String |
getCharset() |
String |
getErrorMessage() |
Header |
getHeader() |
String |
getName() |
abstract String |
getStartLine() |
String |
getVersion() |
boolean |
hasMsgReleased() |
boolean |
isBodyEmpty() |
boolean |
isCSS() |
boolean |
isDeflate() |
boolean |
isGzip() |
boolean |
isHTML() |
boolean |
isHTTP10() |
boolean |
isHTTP11() |
boolean |
isImage() |
boolean |
isJavaScript() |
boolean |
isJSON() |
boolean |
isKeepAlive() |
boolean |
isReleased() |
boolean |
isXML() |
protected abstract void |
parseStartLine(InputStream in) |
void |
read(InputStream in,
boolean createBody)
If the message is HTTP 1.1 but the header has no information about the
content length, then an assumption is made that after the body the server
will send an EOF.
|
void |
readBody() |
void |
release()
preserve synchronized keyword, notify method is called
|
void |
setBody(AbstractBody b)
Sets the body.
|
void |
setBodyContent(byte[] content)
Sets the body.
|
void |
setErrorMessage(String errorMessage) |
void |
setHeader(Header srcHeader) |
void |
setReleased(boolean released) |
void |
setVersion(String version) |
String |
toString() |
void |
write(OutputStream out) |
void |
writeStartLine(OutputStream out)
The start line supposedly only contains ASCII characters.
|
protected Header header
protected AbstractBody body
protected String version
public void read(InputStream in, boolean createBody) throws IOException, EndOfStreamException
IOExceptionEndOfStreamExceptionpublic void readBody()
throws IOException
IOExceptionpublic void discardBody()
throws IOException
IOExceptionpublic AbstractBody getBody()
public InputStream getBodyAsStream()
Probably you want to use getBodyAsStreamDecoded() instead:
Transfer-Encodings (e.g. chunking) have been unapplied, but Content-Encodings (e.g. gzip) have not.
Returns the body as a stream.
Supports streaming: The HTTP message does not have to be completely received yet for this method to return.
AbstractBody.getContentAsStream()public InputStream getBodyAsStreamDecoded()
Returns the logical body content.
Any Transfer-Encodings (e.g. chunking) and/or Content-Encodings (e.g. gzip) have been unapplied.
Supports streaming: The HTTP message does not have to be completely received yet for this method to return.
public String getBodyAsStringDecoded()
As this method has bad performance, it should not be used in any critical component.
(Use getBodyAsStreamDecoded() instead.)
Allocates a new String object for the whole body (potentially performing charset conversion).
Blocks until the body has been fully received.
(... and more bad internal performance)
public void setBody(AbstractBody b)
setBodyContent(byte[]) instead.public void setBodyContent(byte[] content)
protected void createBody(InputStream in) throws IOException
IOExceptionprotected abstract void parseStartLine(InputStream in) throws IOException, EndOfStreamException
IOExceptionEndOfStreamExceptionpublic Header getHeader()
public void release()
public boolean hasMsgReleased()
public void setHeader(Header srcHeader)
public final void write(OutputStream out) throws IOException
IOExceptionpublic void writeStartLine(OutputStream out) throws IOException
HttpUtil.readLine(InputStream) converts the input byte-by-byte
to char-by-char, we use ISO-8859-1 for output.IOExceptionpublic abstract String getStartLine()
public boolean isHTTP11()
public boolean isHTTP10()
public String getVersion()
public void setVersion(String version)
public boolean isKeepAlive()
public String getErrorMessage()
public void setErrorMessage(String errorMessage)
public String getName()
public boolean isBodyEmpty()
throws IOException
IOExceptionpublic boolean isImage()
public boolean isXML()
public boolean isJSON()
public boolean isHTML()
public boolean isCSS()
public boolean isJavaScript()
public boolean isGzip()
public boolean isDeflate()
public String getCharset()
public void addObserver(MessageObserver observer)
public int estimateHeapSize()
public abstract <T extends Message> T createSnapshot() throws Exception
Exceptionpublic <T extends Message> T createMessageSnapshot(T result) throws IOException
IOExceptionpublic boolean isReleased()
public void setReleased(boolean released)
public boolean containsObserver(MessageObserver obs)
Copyright © 2019. All Rights Reserved.