Class 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 Detail

      • HttpConnection

        public HttpConnection​(long requestId,
                              javax.servlet.AsyncContext context)
        Constructs an HTTP Connection.
        Parameters:
        requestId - the ID which uniquely identifies this request.
        context - execution context of the servlet request that created this instance.
    • Method Detail

      • 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.
      • isSecure

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

        public void deliverBody​(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
      • getRequestId

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

        public HttpSession getSession()
        Returns the session that this connection belongs to.
        Returns:
        the session that this connection belongs to.
      • getRemoteAddr

        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,
      • getPeerCertificates

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