|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCADI.Server.Network.HTTPResponseSender
public class HTTPResponseSender
This class implements a wrapper to send an HTTP Response.
| Field Summary | |
|---|---|
private boolean |
chunkedMode
Not used yet. |
private static java.lang.String |
CRLF
Is the carriage-return and line-feed characters. |
static byte[] |
CRLF_Bytes
Is the carriage and return line-feed bytes. |
private static java.lang.String |
HTTP_VERSION_11
|
private float |
maxTxRate
Definition in Scheduler.maxTxRate. |
private java.io.OutputStream |
os
Is an output stream that will be used to send the server response to the client. |
private long[] |
sentBytes
|
private long[] |
times
|
| Constructor Summary | |
|---|---|
HTTPResponseSender(java.io.OutputStream os)
Constructor. |
|
| Method Summary | |
|---|---|
void |
endOfChunk()
Sends the end of the chunk. |
void |
endOfHeaders()
|
void |
flush()
Flushes this output stream and forces any buffered output bytes to be sent. |
void |
sendChunk(byte[] chunk)
Sends a chunk of the HTTP body. |
void |
sendChunks(byte[]... args)
Sends multiple chunks as a only one chunk. |
void |
sendHeader(java.lang.String header)
|
void |
sendHeader(java.lang.String key,
java.lang.String value)
|
void |
sendHeaders(HTTPResponse headers)
Sends the HTTP protocol's headers. |
void |
sendHeaders(java.lang.String... args)
|
void |
setMaxTxRate(float maxTxRate)
Sets the maxTxRate attribute. |
private void |
updateBytesSentAndTimes(long bytes,
long time)
This method updates the #bytesSent and times attributes
with new new values which are parssed as input parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String CRLF
public static final byte[] CRLF_Bytes
private java.io.OutputStream os
private float maxTxRate
Scheduler.maxTxRate. But a O
value does not mean unlimited rate delivery, it means to delivery at
0 bytes/sec.
private static final java.lang.String HTTP_VERSION_11
private boolean chunkedMode
private long[] sentBytes
private long[] times
| Constructor Detail |
|---|
public HTTPResponseSender(java.io.OutputStream os)
os - the output stream to send the HTTP data.
java.lang.NullPointerException - if the output stream parameter is null.| Method Detail |
|---|
public final void setMaxTxRate(float maxTxRate)
maxTxRate attribute.
maxTxRate - definition in maxTxRate.
public void sendHeaders(HTTPResponse headers)
throws java.io.IOException
headers - the HTTP protocol's header to send.
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void sendHeaders(java.lang.String... args)
throws java.io.IOException
args -
java.io.IOException
public void sendHeader(java.lang.String header)
throws java.io.IOException
header -
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void sendHeader(java.lang.String key,
java.lang.String value)
throws java.io.IOException
key - value -
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void endOfHeaders()
throws java.io.IOException
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void sendChunk(byte[] chunk)
throws java.io.IOException
chunk data is
null, this method returns and does nothing.
This method is only used when the HTTP chunked mode mode is set.
- Parameters:
chunk - a byte array with chunk data to send.
- Throws:
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void sendChunks(byte[]... args)
throws java.io.IOException
chunk
parameter is null, it is discarded.
This method is only used when the HTTP chunked mode mode is set.
- Parameters:
args - the chunk data
- Throws:
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void flush()
throws java.io.IOException
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
public void endOfChunk()
throws java.io.IOException
java.io.IOException - if there is not connection to the remote host or the
operation has been interrupted.
private void updateBytesSentAndTimes(long bytes,
long time)
#bytesSent and times attributes
with new new values which are parssed as input parameters.
bytes - the new value to be added in the #bytesSent
attribute.time - the new value to be added in the times attribute.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||