Package org.eclipse.jetty.server
Class HttpConnection
- java.lang.Object
-
- org.eclipse.jetty.io.AbstractConnection
-
- org.eclipse.jetty.server.HttpConnection
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
,org.eclipse.jetty.io.Connection
,org.eclipse.jetty.io.Connection.UpgradeFrom
,org.eclipse.jetty.io.Connection.UpgradeTo
,org.eclipse.jetty.io.WriteFlusher.Listener
,HttpTransport
public class HttpConnection extends org.eclipse.jetty.io.AbstractConnection implements java.lang.Runnable, HttpTransport, org.eclipse.jetty.io.WriteFlusher.Listener, org.eclipse.jetty.io.Connection.UpgradeFrom, org.eclipse.jetty.io.Connection.UpgradeTo
A
Connection
that handles the HTTP protocol.
-
-
Field Summary
Fields Modifier and Type Field Description static org.eclipse.jetty.http.HttpField
CONNECTION_CLOSE
static java.lang.String
UPGRADE_CONNECTION_ATTRIBUTE
-
Constructor Summary
Constructors Constructor Description HttpConnection(HttpConfiguration config, Connector connector, org.eclipse.jetty.io.EndPoint endPoint, org.eclipse.jetty.http.HttpCompliance compliance, boolean recordComplianceViolations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(java.lang.Throwable failure)
Aborts this transport.void
asyncReadFillInterested()
void
blockingReadFailure(java.lang.Throwable e)
void
blockingReadFillInterested()
protected boolean
fillAndParseForContent()
Fill and parse data looking for contentlong
getBytesIn()
long
getBytesOut()
Connector
getConnector()
static HttpConnection
getCurrentConnection()
Get the current connection that this thread is dispatched to.org.eclipse.jetty.http.HttpGenerator
getGenerator()
HttpChannel
getHttpChannel()
HttpConfiguration
getHttpConfiguration()
long
getMessagesIn()
long
getMessagesOut()
org.eclipse.jetty.http.HttpParser
getParser()
java.nio.ByteBuffer
getRequestBuffer()
Server
getServer()
boolean
isOptimizedForDirectBuffers()
Is the underlying transport optimized for DirectBuffer usageboolean
isPushSupported()
boolean
isRecordHttpComplianceViolations()
boolean
isRequestBufferEmpty()
protected HttpChannelOverHttp
newHttpChannel()
protected org.eclipse.jetty.http.HttpGenerator
newHttpGenerator()
protected org.eclipse.jetty.http.HttpParser
newHttpParser(org.eclipse.jetty.http.HttpCompliance compliance)
protected org.eclipse.jetty.http.HttpParser.RequestHandler
newRequestHandler()
void
onClose()
void
onCompleted()
Called to indicated the end of the current request/response cycle (which may be some time after the last content is sent).void
onFillable()
protected void
onFillInterestedFailed(java.lang.Throwable cause)
void
onFlushed(long bytes)
void
onOpen()
protected boolean
onReadTimeout(java.lang.Throwable timeout)
java.nio.ByteBuffer
onUpgradeFrom()
void
onUpgradeTo(java.nio.ByteBuffer buffer)
void
push(org.eclipse.jetty.http.MetaData.Request request)
void
run()
void
send(org.eclipse.jetty.http.MetaData.Response info, boolean head, java.nio.ByteBuffer content, boolean lastContent, org.eclipse.jetty.util.Callback callback)
Asynchronous call to send a response (or part) over the transportprotected static HttpConnection
setCurrentConnection(HttpConnection connection)
java.lang.String
toConnectionString()
-
Methods inherited from class org.eclipse.jetty.io.AbstractConnection
addListener, close, failedCallback, fillInterested, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, isFillInterested, onIdleExpired, removeListener, setInputBufferSize, toString, tryFillInterested, tryFillInterested
-
-
-
-
Field Detail
-
CONNECTION_CLOSE
public static final org.eclipse.jetty.http.HttpField CONNECTION_CLOSE
-
UPGRADE_CONNECTION_ATTRIBUTE
public static final java.lang.String UPGRADE_CONNECTION_ATTRIBUTE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpConnection
public HttpConnection(HttpConfiguration config, Connector connector, org.eclipse.jetty.io.EndPoint endPoint, org.eclipse.jetty.http.HttpCompliance compliance, boolean recordComplianceViolations)
-
-
Method Detail
-
getCurrentConnection
public static HttpConnection getCurrentConnection()
Get the current connection that this thread is dispatched to. Note that a thread may be processing a request asynchronously and thus not be dispatched to the connection.- Returns:
- the current HttpConnection or null
- See Also:
for a more general way to access the HttpConnection
-
setCurrentConnection
protected static HttpConnection setCurrentConnection(HttpConnection connection)
-
getHttpConfiguration
public HttpConfiguration getHttpConfiguration()
-
isRecordHttpComplianceViolations
public boolean isRecordHttpComplianceViolations()
-
newHttpGenerator
protected org.eclipse.jetty.http.HttpGenerator newHttpGenerator()
-
newHttpChannel
protected HttpChannelOverHttp newHttpChannel()
-
newHttpParser
protected org.eclipse.jetty.http.HttpParser newHttpParser(org.eclipse.jetty.http.HttpCompliance compliance)
-
newRequestHandler
protected org.eclipse.jetty.http.HttpParser.RequestHandler newRequestHandler()
-
getServer
public Server getServer()
-
getConnector
public Connector getConnector()
-
getHttpChannel
public HttpChannel getHttpChannel()
-
getParser
public org.eclipse.jetty.http.HttpParser getParser()
-
getGenerator
public org.eclipse.jetty.http.HttpGenerator getGenerator()
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
Description copied from interface:HttpTransport
Is the underlying transport optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffers
in interfaceHttpTransport
- Returns:
- True if direct buffers can be used optimally.
-
getMessagesIn
public long getMessagesIn()
- Specified by:
getMessagesIn
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getMessagesIn
in classorg.eclipse.jetty.io.AbstractConnection
-
getMessagesOut
public long getMessagesOut()
- Specified by:
getMessagesOut
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getMessagesOut
in classorg.eclipse.jetty.io.AbstractConnection
-
onUpgradeFrom
public java.nio.ByteBuffer onUpgradeFrom()
- Specified by:
onUpgradeFrom
in interfaceorg.eclipse.jetty.io.Connection.UpgradeFrom
-
onUpgradeTo
public void onUpgradeTo(java.nio.ByteBuffer buffer)
- Specified by:
onUpgradeTo
in interfaceorg.eclipse.jetty.io.Connection.UpgradeTo
-
onFlushed
public void onFlushed(long bytes) throws java.io.IOException
- Specified by:
onFlushed
in interfaceorg.eclipse.jetty.io.WriteFlusher.Listener
- Throws:
java.io.IOException
-
getRequestBuffer
public java.nio.ByteBuffer getRequestBuffer()
-
isRequestBufferEmpty
public boolean isRequestBufferEmpty()
-
onFillable
public void onFillable()
- Specified by:
onFillable
in classorg.eclipse.jetty.io.AbstractConnection
-
fillAndParseForContent
protected boolean fillAndParseForContent()
Fill and parse data looking for content- Returns:
- true if an
HttpParser.RequestHandler
method was called and it returned true;
-
onCompleted
public void onCompleted()
Description copied from interface:HttpTransport
Called to indicated the end of the current request/response cycle (which may be some time after the last content is sent).- Specified by:
onCompleted
in interfaceHttpTransport
-
onReadTimeout
protected boolean onReadTimeout(java.lang.Throwable timeout)
- Overrides:
onReadTimeout
in classorg.eclipse.jetty.io.AbstractConnection
-
onFillInterestedFailed
protected void onFillInterestedFailed(java.lang.Throwable cause)
- Overrides:
onFillInterestedFailed
in classorg.eclipse.jetty.io.AbstractConnection
-
onOpen
public void onOpen()
- Specified by:
onOpen
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
onOpen
in classorg.eclipse.jetty.io.AbstractConnection
-
onClose
public void onClose()
- Specified by:
onClose
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
onClose
in classorg.eclipse.jetty.io.AbstractConnection
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
send
public void send(org.eclipse.jetty.http.MetaData.Response info, boolean head, java.nio.ByteBuffer content, boolean lastContent, org.eclipse.jetty.util.Callback callback)
Description copied from interface:HttpTransport
Asynchronous call to send a response (or part) over the transport- Specified by:
send
in interfaceHttpTransport
- Parameters:
info
- The header info to send, or null if just sending more data. The first call to send for a response must have a non null info.head
- True if the response if for a HEAD request (and the data should not be sent).content
- A buffer of content to be sent.lastContent
- True if the content is the last content for the current response.callback
- The Callback instance that success or failure of the send is notified on
-
abort
public void abort(java.lang.Throwable failure)
Description copied from interface:HttpTransport
Aborts this transport.This method should terminate the transport in a way that can indicate an abnormal response to the client, for example by abruptly close the connection.
This method is called when an error response needs to be sent, but the response is already committed, or when a write failure is detected. If abort is called,
HttpTransport.onCompleted()
is not called- Specified by:
abort
in interfaceHttpTransport
- Parameters:
failure
- the failure that caused the abort.
-
isPushSupported
public boolean isPushSupported()
- Specified by:
isPushSupported
in interfaceHttpTransport
- Returns:
- true if responses can be pushed over this transport
-
push
public void push(org.eclipse.jetty.http.MetaData.Request request)
- Specified by:
push
in interfaceHttpTransport
- Parameters:
request
- A request to use as the basis for generating a pushed response.
-
asyncReadFillInterested
public void asyncReadFillInterested()
-
blockingReadFillInterested
public void blockingReadFillInterested()
-
blockingReadFailure
public void blockingReadFailure(java.lang.Throwable e)
-
getBytesIn
public long getBytesIn()
- Specified by:
getBytesIn
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getBytesIn
in classorg.eclipse.jetty.io.AbstractConnection
-
getBytesOut
public long getBytesOut()
- Specified by:
getBytesOut
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getBytesOut
in classorg.eclipse.jetty.io.AbstractConnection
-
toConnectionString
public java.lang.String toConnectionString()
- Overrides:
toConnectionString
in classorg.eclipse.jetty.io.AbstractConnection
-
-