org.eclipse.jetty.http
Class AbstractGenerator
java.lang.Object
org.eclipse.jetty.http.AbstractGenerator
- All Implemented Interfaces:
- Generator
- Direct Known Subclasses:
- Ajp13Generator, HttpGenerator, NestedGenerator
public abstract class AbstractGenerator
- extends Object
- implements Generator
Abstract Generator. Builds HTTP Messages.
Currently this class uses a system parameter "jetty.direct.writers" to control
two optional writer to byte conversions. buffer.writers=true will probably be
faster, but will consume more memory. This option is just for testing and tuning.
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
NO_BYTES
public static final byte[] NO_BYTES
_buffers
protected final Buffers _buffers
_endp
protected final EndPoint _endp
_state
protected int _state
_status
protected int _status
_version
protected int _version
_reason
protected Buffer _reason
_method
protected Buffer _method
_uri
protected String _uri
_contentWritten
protected long _contentWritten
_contentLength
protected long _contentLength
_last
protected boolean _last
_head
protected boolean _head
_noContent
protected boolean _noContent
_persistent
protected Boolean _persistent
_header
protected Buffer _header
_buffer
protected Buffer _buffer
_content
protected Buffer _content
_date
protected Buffer _date
AbstractGenerator
public AbstractGenerator(Buffers buffers,
EndPoint io)
- Constructor.
- Parameters:
buffers
- buffer poolio
- the end point
isRequest
public abstract boolean isRequest()
isResponse
public abstract boolean isResponse()
isOpen
public boolean isOpen()
reset
public void reset()
- Specified by:
reset
in interface Generator
returnBuffers
public void returnBuffers()
- Specified by:
returnBuffers
in interface Generator
resetBuffer
public void resetBuffer()
- Specified by:
resetBuffer
in interface Generator
getContentBufferSize
public int getContentBufferSize()
- Specified by:
getContentBufferSize
in interface Generator
- Returns:
- Returns the contentBufferSize.
increaseContentBufferSize
public void increaseContentBufferSize(int contentBufferSize)
- Specified by:
increaseContentBufferSize
in interface Generator
- Parameters:
contentBufferSize
- The contentBufferSize to set.
getUncheckedBuffer
public Buffer getUncheckedBuffer()
getSendServerVersion
public boolean getSendServerVersion()
setSendServerVersion
public void setSendServerVersion(boolean sendServerVersion)
- Specified by:
setSendServerVersion
in interface Generator
getState
public int getState()
isState
public boolean isState(int state)
isComplete
public boolean isComplete()
- Specified by:
isComplete
in interface Generator
isIdle
public boolean isIdle()
- Specified by:
isIdle
in interface Generator
isCommitted
public boolean isCommitted()
- Specified by:
isCommitted
in interface Generator
isHead
public boolean isHead()
- Returns:
- Returns the head.
setContentLength
public void setContentLength(long value)
- Specified by:
setContentLength
in interface Generator
setHead
public void setHead(boolean head)
- Specified by:
setHead
in interface Generator
- Parameters:
head
- The head to set.
isPersistent
public boolean isPersistent()
- Specified by:
isPersistent
in interface Generator
- Returns:
false
if the connection should be closed after a request has been read,
true
if it should be used for additional requests.
setPersistent
public void setPersistent(boolean persistent)
- Specified by:
setPersistent
in interface Generator
setVersion
public void setVersion(int version)
- Specified by:
setVersion
in interface Generator
- 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).
getVersion
public int getVersion()
setDate
public void setDate(Buffer timeStampBuffer)
- Specified by:
setDate
in interface Generator
- See Also:
Generator.setDate(org.eclipse.jetty.io.Buffer)
setRequest
public void setRequest(String method,
String uri)
- Specified by:
setRequest
in interface Generator
setResponse
public void setResponse(int status,
String reason)
- Specified by:
setResponse
in interface Generator
- Parameters:
status
- The status code to send.reason
- the status message to send.
prepareUncheckedAddContent
public abstract int prepareUncheckedAddContent()
throws IOException
- Prepare buffer for unchecked writes.
Prepare the generator buffer to receive unchecked writes
- Returns:
- the available space in the buffer.
- Throws:
IOException
completeUncheckedAddContent
public void completeUncheckedAddContent()
isBufferFull
public boolean isBufferFull()
- Specified by:
isBufferFull
in interface Generator
isWritten
public boolean isWritten()
- Specified by:
isWritten
in interface Generator
isAllContentWritten
public boolean isAllContentWritten()
- Specified by:
isAllContentWritten
in interface Generator
completeHeader
public abstract void completeHeader(HttpFields fields,
boolean allContentAdded)
throws IOException
- Specified by:
completeHeader
in interface Generator
- Throws:
IOException
complete
public void complete()
throws IOException
- Complete the message.
- Specified by:
complete
in interface Generator
- Throws:
IOException
flushBuffer
public abstract int flushBuffer()
throws IOException
- Specified by:
flushBuffer
in interface Generator
- Throws:
IOException
flush
public void flush(long maxIdleTime)
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.
- Specified by:
sendError
in interface Generator
- Parameters:
code
- The error codereason
- The error reasoncontent
- Contents of the error pageclose
- True if the connection should be closed
- Throws:
IOException
- if there is a problem flushing the response
getContentWritten
public long getContentWritten()
- Specified by:
getContentWritten
in interface Generator
- Returns:
- Returns the contentWritten.
blockForOutput
public void blockForOutput(long maxIdleTime)
throws IOException
- Throws:
IOException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.