Package io.muserver

Interface HttpConnection


  • public interface HttpConnection
    A connection between a server and a client.
    • Method Detail

      • protocol

        java.lang.String protocol()
        The HTTP protocol for the request.
        Returns:
        A string such as HTTP/1.1 or HTTP/2
      • isHttps

        boolean isHttps()
        Returns:
        true if the connnection is secured over HTTPS, otherwise false
      • httpsProtocol

        java.lang.String httpsProtocol()
        Gets the HTTPS protocol, for example "TLSv1.2" or "TLSv1.3"
        Returns:
        The HTTPS protocol being used, or null if this connection is not over HTTPS.
      • cipher

        java.lang.String cipher()
        Returns:
        The HTTPS cipher used on this connection, or null if this connection is not over HTTPS.
      • startTime

        java.time.Instant startTime()
        Returns:
        The time that this connection was established.
      • remoteAddress

        java.net.InetSocketAddress remoteAddress()
        Returns:
        The socket address of the client.
      • completedRequests

        long completedRequests()
        Returns:
        The number of completed requests on this connection.
      • invalidHttpRequests

        long invalidHttpRequests()
        Returns:
        The number of requests received that were not valid HTTP messages.
      • activeRequests

        java.util.Set<MuRequest> activeRequests()
        Returns:
        A readonly connection of requests that are in progress on this connection
      • activeWebsockets

        java.util.Set<MuWebSocket> activeWebsockets()
        The websockets on this connection.

        Note that in Mu Server websockets are only on HTTP/1.1 connections and there is a 1:1 mapping between a websocket and an HTTP Connection. This means the returned set is either empty or has a size of 1.

        Returns:
        A readonly set of active websockets being used on this connection
      • server

        MuServer server()
        Returns:
        The server that this connection belongs to
      • clientCertificate

        java.util.Optional<java.security.cert.Certificate> clientCertificate()
        Gets the TLS certificate the client sent.

        The returned certificate will be Optional.empty() when:

        Returns:
        The client certificate, or empty if no certificate is available