|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
rabbit.io.HTTPOutputStream
This is an extended DataOutputstream suitable for writing HTTP data. This class handles sending data in chunked manner, set the "Transfer-Encoding" header to "chunked" in the HTTPHeader before sending it to specify it. If you are sending data in chunked mode you must end it correctly. There is two ways to do that: Use the finish method (will use an empty footer) or Manually send a zero sized block followed by the HTTPFooter. Something like this:
Constructor Summary | |
HTTPOutputStream(java.io.OutputStream is)
Create a new HTTPOutputStream on the underlying stream. |
|
HTTPOutputStream(java.io.OutputStream is,
boolean ischunked)
Create a new HTTPOutputStream on the underlying stream. |
Method Summary | |
void |
finish()
This will make sure the stream is finished. |
boolean |
isChunking()
Check if this stream is chunking. |
void |
write(byte[] buf)
Write a byte array to the underlying stream. |
void |
write(byte[] buf,
int off,
int len)
Write a byte array to the underlying stream. |
void |
write(int b)
Write a byte to the underlying stream. |
void |
writeFooter(HTTPFooter footer)
Write a HTTPFooter on this stream. |
void |
writeHTTPHeader(HTTPHeader header)
Write a HTTPHeader on this stream. |
Methods inherited from class java.io.DataOutputStream |
flush, size, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
Methods inherited from class java.io.FilterOutputStream |
close |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HTTPOutputStream(java.io.OutputStream is)
is
- the underlying stream.public HTTPOutputStream(java.io.OutputStream is, boolean ischunked)
is
- the underlying stream.Method Detail |
public boolean isChunking()
public void writeHTTPHeader(HTTPHeader header) throws java.io.IOException
header
- the HTTPHeader to write.
java.io.IOException
- if the header could not be written correctly.public void write(int b) throws java.io.IOException
b
- the byte to write.
java.io.IOException
- if the underlying write does.public void write(byte[] buf) throws java.io.IOException
buf
- the byte array to write.
java.io.IOException
- if the underlying write does.public void write(byte[] buf, int off, int len) throws java.io.IOException
buf
- the byte array to write.off
- the starting offset in the array.len
- the number of bytes to write.
java.io.IOException
- if the underlying write does.public void writeFooter(HTTPFooter footer) throws java.io.IOException
footer
- the HTTPFooter to write.
java.io.IOException
public void finish() throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |