Package io.muserver
Interface HttpConnection
-
public interface HttpConnection
A connection between a server and a client.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<MuRequest>
activeRequests()
java.util.Set<MuWebSocket>
activeWebsockets()
The websockets on this connection.java.lang.String
cipher()
java.util.Optional<java.security.cert.Certificate>
clientCertificate()
Gets the TLS certificate the client sent.long
completedRequests()
java.lang.String
httpsProtocol()
Gets the HTTPS protocol, for example "TLSv1.2" or "TLSv1.3"long
invalidHttpRequests()
boolean
isHttps()
java.lang.String
protocol()
The HTTP protocol for the request.java.util.Optional<ProxiedConnectionInfo>
proxyInfo()
Gets information from a proxy that uses the HA Proxy protocol.long
rejectedDueToOverload()
java.net.InetSocketAddress
remoteAddress()
MuServer
server()
java.time.Instant
startTime()
-
-
-
Method Detail
-
protocol
java.lang.String protocol()
The HTTP protocol for the request.- Returns:
- A string such as
HTTP/1.1
orHTTP/2
-
isHttps
boolean isHttps()
- Returns:
true
if the connnection is secured over HTTPS, otherwisefalse
-
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.
-
rejectedDueToOverload
long rejectedDueToOverload()
- Returns:
- The number of requests rejected because the executor passed to
MuServerBuilder.withHandlerExecutor(ExecutorService)
rejected a new response.
-
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:- The client did not send a certificate, or
- The client sent a certificate that failed verification with the client trust manager, or
- No client trust manager was set with
HttpsConfigBuilder.withClientCertificateTrustManager(TrustManager)
, or - The request was not sent over HTTPS
- Returns:
- The client certificate, or
empty
if no certificate is available
-
proxyInfo
java.util.Optional<ProxiedConnectionInfo> proxyInfo()
Gets information from a proxy that uses the HA Proxy protocol.Note: this is only available if enabled via
MuServerBuilder.withHAProxyProtocolEnabled(boolean)
- Returns:
- Information from a proxy about the source client, or
Optional.empty()
if none specified.
-
-