class MessageWriter extends Object
Modifier and Type | Class and Description |
---|---|
private class |
MessageWriter.ChunkedOutputStream
Output stream for writing chunked transfer-coded content.
|
Modifier and Type | Field and Description |
---|---|
private static int |
CHUNK_SIZE |
private static int |
CONTENT |
private OutputStream |
cout |
private static int |
DONE |
private Header |
header |
private static int |
HEADER |
private OutputStream |
out |
private static int |
START |
private int |
state |
Constructor and Description |
---|
MessageWriter(OutputStream out,
boolean chunked)
Creates new writer on top of given output stream.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
flush()
Flushes written data to underlying output stream.
|
private void |
updateState(int oldState,
int newState) |
(package private) void |
writeContent(byte[] b,
int off,
int len)
Writes message content.
|
(package private) void |
writeHeader(Header header)
"Writes" HTTP message header (the header may not actually be written
until after the message content length is known).
|
(package private) static void |
writeLine(OutputStream out,
String line)
Writes line to given output stream in ASCII, terminated by HTTP
end-of-line sequence "\r\n".
|
(package private) void |
writeStartLine(StartLine line)
Writes HTTP message start line.
|
(package private) void |
writeTrailer(Header trailer)
Writes message trailer (if not using chunked output, merges trailer with
header before writing), completing message output.
|
private static final int CHUNK_SIZE
private static final int START
private static final int HEADER
private static final int CONTENT
private static final int DONE
private final OutputStream out
private final OutputStream cout
private int state
private Header header
MessageWriter(OutputStream out, boolean chunked)
void writeStartLine(StartLine line) throws IOException
IOException
void writeHeader(Header header) throws IOException
IOException
void writeContent(byte[] b, int off, int len) throws IOException
IOException
void writeTrailer(Header trailer) throws IOException
IOException
void flush() throws IOException
IOException
static void writeLine(OutputStream out, String line) throws IOException
IOException
private void updateState(int oldState, int newState)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.