Class HttpConnection

java.lang.Object
org.eclipse.jetty.io.AbstractConnection
org.eclipse.jetty.server.HttpConnection
All Implemented Interfaces:
Closeable, AutoCloseable, 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 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 Details

    • CONNECTION_CLOSE

      public static final org.eclipse.jetty.http.HttpField CONNECTION_CLOSE
  • Constructor Details

    • HttpConnection

      public HttpConnection(HttpConfiguration config, Connector connector, org.eclipse.jetty.io.EndPoint endPoint, boolean recordComplianceViolations)
  • Method Details

    • 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:
    • setCurrentConnection

      protected static HttpConnection setCurrentConnection(HttpConnection connection)
    • getBeginNanoTime

      public long getBeginNanoTime()
    • 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()
    • getMessagesIn

      public long getMessagesIn()
      Specified by:
      getMessagesIn in interface org.eclipse.jetty.io.Connection
      Overrides:
      getMessagesIn in class org.eclipse.jetty.io.AbstractConnection
    • getMessagesOut

      public long getMessagesOut()
      Specified by:
      getMessagesOut in interface org.eclipse.jetty.io.Connection
      Overrides:
      getMessagesOut in class org.eclipse.jetty.io.AbstractConnection
    • isUseInputDirectByteBuffers

      public boolean isUseInputDirectByteBuffers()
    • setUseInputDirectByteBuffers

      public void setUseInputDirectByteBuffers(boolean useInputDirectByteBuffers)
    • isUseOutputDirectByteBuffers

      public boolean isUseOutputDirectByteBuffers()
    • setUseOutputDirectByteBuffers

      public void setUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers)
    • onUpgradeFrom

      public ByteBuffer onUpgradeFrom()
      Specified by:
      onUpgradeFrom in interface org.eclipse.jetty.io.Connection.UpgradeFrom
    • onUpgradeTo

      public void onUpgradeTo(ByteBuffer buffer)
      Specified by:
      onUpgradeTo in interface org.eclipse.jetty.io.Connection.UpgradeTo
    • onFlushed

      public void onFlushed(long bytes) throws IOException
      Specified by:
      onFlushed in interface org.eclipse.jetty.io.WriteFlusher.Listener
      Throws:
      IOException
    • isRequestBufferEmpty

      public boolean isRequestBufferEmpty()
    • onFillable

      public void onFillable()
      Specified by:
      onFillable in class org.eclipse.jetty.io.AbstractConnection
    • 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 interface HttpTransport
    • onReadTimeout

      protected boolean onReadTimeout(Throwable timeout)
      Overrides:
      onReadTimeout in class org.eclipse.jetty.io.AbstractConnection
    • onFillInterestedFailed

      protected void onFillInterestedFailed(Throwable cause)
      Overrides:
      onFillInterestedFailed in class org.eclipse.jetty.io.AbstractConnection
    • onOpen

      public void onOpen()
      Specified by:
      onOpen in interface org.eclipse.jetty.io.Connection
      Overrides:
      onOpen in class org.eclipse.jetty.io.AbstractConnection
    • onClose

      public void onClose(Throwable cause)
      Specified by:
      onClose in interface org.eclipse.jetty.io.Connection
      Overrides:
      onClose in class org.eclipse.jetty.io.AbstractConnection
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • send

      public void send(org.eclipse.jetty.http.MetaData.Request request, org.eclipse.jetty.http.MetaData.Response response, 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 interface HttpTransport
      Parameters:
      request - True if the response if for a HEAD request (and the data should not be sent).
      response - 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.
      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(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 interface HttpTransport
      Parameters:
      failure - the failure that caused the abort.
    • isPushSupported

      public boolean isPushSupported()
      Specified by:
      isPushSupported in interface HttpTransport
      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 interface HttpTransport
      Parameters:
      request - A request to use as the basis for generating a pushed response.
    • asyncReadFillInterested

      public void asyncReadFillInterested()
    • getBytesIn

      public long getBytesIn()
      Specified by:
      getBytesIn in interface org.eclipse.jetty.io.Connection
      Overrides:
      getBytesIn in class org.eclipse.jetty.io.AbstractConnection
    • getBytesOut

      public long getBytesOut()
      Specified by:
      getBytesOut in interface org.eclipse.jetty.io.Connection
      Overrides:
      getBytesOut in class org.eclipse.jetty.io.AbstractConnection
    • toConnectionString

      public String toConnectionString()
      Overrides:
      toConnectionString in class org.eclipse.jetty.io.AbstractConnection