Class HttpConnection

java.lang.Object
org.jivesoftware.openfire.http.HttpConnection

public class HttpConnection extends Object
Represents one HTTP connection with a client using the HTTP Binding service. The client will wait on a response until the server forwards a message to it or the wait time on the session timeout.
Author:
Alexander Wenckus
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpConnection(HttpBindBody body, javax.servlet.AsyncContext context)
    Constructs an HTTP Connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The connection should be closed without delivering a stanza to the requestor.
    void
    deliverBody(String body, boolean async)
    Delivers content to the client.
    List<org.dom4j.Element>
    The list of stanzas that was sent by the client to the server over this connection.
    Returns the number of seconds of pause that the client is requesting, or null if it's not requesting a pause.
    Returns the peer certificates for this connection.
    Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
    long
    Returns the ID which uniquely identifies this connection.
    Returns the session that this connection belongs to.
    boolean
    Returns true if this connection has been closed, either a response was delivered to the client or the server closed the connection abruptly.
    boolean
    Returns true if this connection is using HTTPS.
    boolean
    Returns if the request that was sent is a request is polling for data, without providing any data itself.
    boolean
    Returns if the request that was sent is a 'restart request'.
    boolean
    Returns if the request that was sent is a request to terminate the session.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HttpConnection

      public HttpConnection(@Nonnull HttpBindBody body, @Nonnull javax.servlet.AsyncContext context)
      Constructs an HTTP Connection.
      Parameters:
      body - the BOSH data that is in this request.
      context - execution context of the servlet request that created this instance.
  • Method Details

    • close

      public void close()
      The connection should be closed without delivering a stanza to the requestor.
    • isClosed

      public boolean isClosed()
      Returns true if this connection has been closed, either a response was delivered to the client or the server closed the connection abruptly.
      Returns:
      true if this connection has been closed.
    • isEncrypted

      public boolean isEncrypted()
      Returns true if this connection is using HTTPS.
      Returns:
      true if this connection is using HTTPS.
    • deliverBody

      public void deliverBody(@Nullable String body, boolean async) throws HttpConnectionClosedException, IOException
      Delivers content to the client. The content should be valid XMPP wrapped inside of a body. A null value for body indicates that the connection should be closed and the client sent an empty body.
      Parameters:
      body - the XMPP content to be forwarded to the client inside of a body tag.
      async - when false, this method blocks until the data has been delivered to the client.
      Throws:
      HttpConnectionClosedException - when this connection to the client has already received a deliverable to forward to the client
      IOException - if an input or output exception occurred
    • getInboundDataQueue

      @Nonnull public List<org.dom4j.Element> getInboundDataQueue()
      The list of stanzas that was sent by the client to the server over this connection. Possibly empty.
      Returns:
      An ordered collection of stanzas (possibly empty).
    • getRequestId

      public long getRequestId()
      Returns the ID which uniquely identifies this connection.
      Returns:
      the ID which uniquely identifies this connection.
    • getSession

      @Nullable public HttpSession getSession()
      Returns the session that this connection belongs to. Although technically, this method can return null, it is expected that a session is bound to this connection almost immediately after it is created.
      Returns:
      the session that this connection belongs to.
    • getRemoteAddr

      @Nonnull public InetAddress getRemoteAddr() throws UnknownHostException
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      Returns:
      IP address of the remote peer
      Throws:
      UnknownHostException - if no IP address for the peer could be found,
    • isRestart

      public boolean isRestart()
      Returns if the request that was sent is a 'restart request'.
      Returns:
      if the request that was sent is a 'restart request'.
    • getPause

      public Duration getPause()
      Returns the number of seconds of pause that the client is requesting, or null if it's not requesting a pause.
      Returns:
      The amount of seconds of pause that is being requested, or null.
    • isTerminate

      public boolean isTerminate()
      Returns if the request that was sent is a request to terminate the session.
      Returns:
      if the request that was sent is a request to terminate the session.
    • isPoll

      public boolean isPoll()
      Returns if the request that was sent is a request is polling for data, without providing any data itself.
      Returns:
      if the request that was sent is a request is polling for data, without providing any data itself.
    • getPeerCertificates

      public X509Certificate[] getPeerCertificates()
      Returns the peer certificates for this connection.
      Returns:
      the peer certificates for this connection or null.
    • toString

      public String toString()
      Overrides:
      toString in class Object