org.mortbay.jetty
Class HttpGenerator
java.lang.Object
org.mortbay.jetty.HttpGenerator
- All Implemented Interfaces:
- HttpTokens
public class HttpGenerator
- extends Object
- implements HttpTokens
HttpGenerator. Builds HTTP Messages.
- Author:
- gregw
Fields inherited from interface org.mortbay.jetty.HttpTokens |
CARRIAGE_RETURN, CHUNKED_CONTENT, COLON, CRLF, EOF_CONTENT, LINE_FEED, NO_CONTENT, SELF_DEFINING_CONTENT, SEMI_COLON, SPACE, TAB, UNKNOWN_CONTENT |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STATE_HEADER
public static final int STATE_HEADER
- See Also:
- Constant Field Values
STATE_CONTENT
public static final int STATE_CONTENT
- See Also:
- Constant Field Values
STATE_FLUSHING
public static final int STATE_FLUSHING
- See Also:
- Constant Field Values
STATE_END
public static final int STATE_END
- See Also:
- Constant Field Values
LAST
public static final boolean LAST
- See Also:
- Constant Field Values
MORE
public static final boolean MORE
- See Also:
- Constant Field Values
LAST_CHUNK
private static byte[] LAST_CHUNK
CONTENT_LENGTH_0
private static byte[] CONTENT_LENGTH_0
CONNECTION_KEEP_ALIVE
private static byte[] CONNECTION_KEEP_ALIVE
CONNECTION_CLOSE
private static byte[] CONNECTION_CLOSE
TRANSFER_ENCODING_CHUNKED
private static byte[] TRANSFER_ENCODING_CHUNKED
SERVER
private static byte[] SERVER
CHUNK_SPACE
private static int CHUNK_SPACE
__reasons
private static String[] __reasons
_state
private int _state
_version
private int _version
_status
private int _status
_reason
private String _reason
_contentWritten
private long _contentWritten
_contentLength
private long _contentLength
_last
private boolean _last
_head
private boolean _head
_close
private boolean _close
_buffers
private Buffers _buffers
_endp
private EndPoint _endp
_header
private Buffer _header
_buffer
private Buffer _buffer
_content
private Buffer _content
_direct
boolean _direct
_needCRLF
private boolean _needCRLF
_needEOC
private boolean _needEOC
_bufferChunked
private boolean _bufferChunked
_headerBufferSize
private int _headerBufferSize
_contentBufferSize
private int _contentBufferSize
HttpGenerator
public HttpGenerator(Buffers buffers,
EndPoint io,
int headerBufferSize,
int contentBufferSize)
- Constructor.
- Parameters:
buffers
- buffer poolheaderBufferSize
- Size of the buffer to allocate for HTTP headercontentBufferSize
- Size of the buffer to allocate for HTTP content
getReason
public static String getReason(int code)
reset
public void reset(boolean returnBuffers)
resetBuffer
public void resetBuffer()
getState
public int getState()
isState
public boolean isState(int state)
isComplete
public boolean isComplete()
isCommitted
public boolean isCommitted()
isHead
public boolean isHead()
- Returns:
- Returns the head.
setHead
public void setHead(boolean head)
- Parameters:
head
- The head to set.
isPersistent
public boolean isPersistent()
- Returns:
getContentAdded
public long getContentAdded()
setVersion
public void setVersion(int version)
- Parameters:
version
- The version of the client the response is being sent to (NB. Not the version
in the response, which is the version of the server).
setRequest
public void setRequest(Buffer method,
Buffer uri)
setResponse
public void setResponse(int status,
String reason)
- Parameters:
status
- The status code to send.reason
- the status message to send.
addContent
public void addContent(Buffer content,
boolean last)
throws IOException
- Add _content.
- Parameters:
_content
-
- Throws:
IOException
isBufferFull
public boolean isBufferFull()
completeHeader
public void completeHeader(HttpFields fields,
boolean allContentAdded)
throws IOException
- Throws:
IOException
complete
public void complete()
throws IOException
- Complete the message.
- Throws:
IOException
flushBuffers
public void flushBuffers()
throws IOException
- Throws:
IOException
prepareBuffers
private void prepareBuffers()
throws IOException
- Throws:
IOException
sendError
public void sendError(int code,
String reason,
String content,
boolean close)
throws IOException
- Utility method to send an error response. If the builder is not committed, this call is
equivalent to a setResponse, addcontent and complete call.
- Parameters:
code
- reason
- _content
- close
-
- Throws:
IOException
getContentBufferSize
public int getContentBufferSize()
- Returns:
- Returns the contentBufferSize.
increaseContentBufferSize
public void increaseContentBufferSize(int contentBufferSize)
- Parameters:
contentBufferSize
- The contentBufferSize to set.
getContentWritten
public long getContentWritten()
- Returns:
- Returns the contentWritten.