Module swim.io.http
Package swim.io.http

Class HttpClientModem

java.lang.Object
swim.io.http.HttpClientModem
All Implemented Interfaces:
FlowContext, HttpClientContext, IpContext, IpModem<HttpResponse<?>,HttpRequest<?>>

public class HttpClientModem extends Object implements IpModem<HttpResponse<?>,HttpRequest<?>>, HttpClientContext
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final HttpClient
     
     
    protected final HttpSettings
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpClientModem(HttpClient client, HttpSettings httpSettings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    become(IpSocket socket)
     
    Returns the cryptographic cipher suite used by the underlying network connection.
    void
     
    void
    Lifecycle callback invoked by the modem context after it has become a new socket implementation.
    void
    Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
    void
    Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
    void
    Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing an error.
    void
    didRead(HttpResponse<?> response)
    I/O callback invoked by the modem context with the completed value of the current read Decoder after it has transitioned to the done state.
    void
    Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
    void
    Lifecycle callback invoked by the modem context after the underlying network connection has timed out.
    void
    didWrite(HttpRequest<?> request)
    I/O callback invoked by the modem context with the completed value of the current write Encoder after it has transitioned to the done state.
    void
    I/O callback invoked by the modem context asking this IpModem to provide an input Decoder by invoking the modem context's read method.
    void
    doRequest(HttpRequester<?> requester)
     
    void
    I/O callback invoked by the modem context asking this IpModem to provide an output Encoder by invoking the modem context's write method.
    Returns the current FlowControl state of the underlying network channel.
    void
    flowControl(FlowControl flowControl)
    Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
    flowControl(FlowModifier flowModifier)
    Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
     
    long
    Returns the number of idle milliseconds after which this IpModem should be closed due to inactivity.
    Returns the socket modem context to which this IpModem is bound; returns null if this IpModem is unbound.
    boolean
    Returns true if the underlying network channel initiated an outgoing connection.
    boolean
    Returns true if the underlying network channel is currently connected.
    boolean
    Returns true if the underlying network transport is encrypted.
    boolean
    Returns true if the underlying network channel accepted an incoming connection.
    Returns the IP address and port of the local endpoint of the underlying network connection.
    Returns the certificate chain used to authenticate the local endpoint of the underlying network connection.
    Returns the authenticated identity of the local endpoint of the underlying network connection.
    void
     
    Returns the IP address and port of the remote endpoint of the underlying network connection.
    Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection.
    Returns the authenticated identity of the remote endpoint of the underlying network connection.
    Returns the name of the transport-layer security protocol used by the underlying network connection.
    void
    Sets the socket modem context to which this IpModem is bound.
    void
    Lifecycle callback invoked by the modem context before it has become a new socket implementation.
    void
    Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
    void
    Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • ipModemContext

      public IpModemContext<HttpResponse<?>,HttpRequest<?>> ipModemContext()
      Description copied from interface: IpModem
      Returns the socket modem context to which this IpModem is bound; returns null if this IpModem is unbound.
      Specified by:
      ipModemContext in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • setIpModemContext

      public void setIpModemContext(IpModemContext<HttpResponse<?>,HttpRequest<?>> context)
      Description copied from interface: IpModem
      Sets the socket modem context to which this IpModem is bound.
      Specified by:
      setIpModemContext in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • idleTimeout

      public long idleTimeout()
      Description copied from interface: IpModem
      Returns the number of idle milliseconds after which this IpModem should be closed due to inactivity. Returns -1 if a default idle timeout should be used. Returns 0 if the underlying network socket should not time out.
      Specified by:
      idleTimeout in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • doRead

      public void doRead()
      Description copied from interface: IpModem
      I/O callback invoked by the modem context asking this IpModem to provide an input Decoder by invoking the modem context's read method. The modem context will asynchronously feed input data to the provided read Decoder until it transitions out of the cont state. The read flow control of the underlying network socket is automatically managed by the modem context using the state of the read Decoder. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead or didRead calls.
      Specified by:
      doRead in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didRead

      public void didRead(HttpResponse<?> response)
      Description copied from interface: IpModem
      I/O callback invoked by the modem context with the completed value of the current read Decoder after it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead or didRead calls.
      Specified by:
      didRead in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • doWrite

      public void doWrite()
      Description copied from interface: IpModem
      I/O callback invoked by the modem context asking this IpModem to provide an output Encoder by invoking the modem context's write method. The modem context will asynchronously pull output data from the provided write Encoder until it transitions out of the cont state. The write flow control of the underlying network socket is automatically managed by the modem context using the state of the write Encoder. May be invoked concurrently to other I/O callbacks, but never concurrently with other doWrite or didWrite calls.
      Specified by:
      doWrite in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didWrite

      public void didWrite(HttpRequest<?> request)
      Description copied from interface: IpModem
      I/O callback invoked by the modem context with the completed value of the current write Encoder after it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with other dodWrite or didWrite calls.
      Specified by:
      didWrite in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • willConnect

      public void willConnect()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
      Specified by:
      willConnect in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didConnect

      public void didConnect()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
      Specified by:
      didConnect in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • willSecure

      public void willSecure()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.
      Specified by:
      willSecure in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didSecure

      public void didSecure()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
      Specified by:
      didSecure in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • willBecome

      public void willBecome(IpSocket socket)
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context before it has become a new socket implementation.
      Specified by:
      willBecome in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didBecome

      public void didBecome(IpSocket socket)
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context after it has become a new socket implementation.
      Specified by:
      didBecome in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didTimeout

      public void didTimeout()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context after the underlying network connection has timed out. The modem will automatically be closed.
      Specified by:
      didTimeout in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didDisconnect

      public void didDisconnect()
      Description copied from interface: IpModem
      Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
      Specified by:
      didDisconnect in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • didFail

      public void didFail(Throwable error)
      Description copied from interface: IpModem
      Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing an error. The modem will automatically be closed.
      Specified by:
      didFail in interface IpModem<HttpResponse<?>,HttpRequest<?>>
    • isConnected

      public boolean isConnected()
      Description copied from interface: IpContext
      Returns true if the underlying network channel is currently connected.
      Specified by:
      isConnected in interface IpContext
    • isClient

      public boolean isClient()
      Description copied from interface: IpContext
      Returns true if the underlying network channel initiated an outgoing connection.
      Specified by:
      isClient in interface IpContext
    • isServer

      public boolean isServer()
      Description copied from interface: IpContext
      Returns true if the underlying network channel accepted an incoming connection.
      Specified by:
      isServer in interface IpContext
    • isSecure

      public boolean isSecure()
      Description copied from interface: IpContext
      Returns true if the underlying network transport is encrypted.
      Specified by:
      isSecure in interface IpContext
    • securityProtocol

      public String securityProtocol()
      Description copied from interface: IpContext
      Returns the name of the transport-layer security protocol used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
      Specified by:
      securityProtocol in interface IpContext
    • cipherSuite

      public String cipherSuite()
      Description copied from interface: IpContext
      Returns the cryptographic cipher suite used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
      Specified by:
      cipherSuite in interface IpContext
    • localAddress

      public InetSocketAddress localAddress()
      Description copied from interface: IpContext
      Returns the IP address and port of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
      Specified by:
      localAddress in interface IpContext
    • localPrincipal

      public Principal localPrincipal()
      Description copied from interface: IpContext
      Returns the authenticated identity of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
      Specified by:
      localPrincipal in interface IpContext
    • localCertificates

      public Collection<Certificate> localCertificates()
      Description copied from interface: IpContext
      Returns the certificate chain used to authenticate the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
      Specified by:
      localCertificates in interface IpContext
    • remoteAddress

      public InetSocketAddress remoteAddress()
      Description copied from interface: IpContext
      Returns the IP address and port of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
      Specified by:
      remoteAddress in interface IpContext
    • remotePrincipal

      public Principal remotePrincipal()
      Description copied from interface: IpContext
      Returns the authenticated identity of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
      Specified by:
      remotePrincipal in interface IpContext
    • remoteCertificates

      public Collection<Certificate> remoteCertificates()
      Description copied from interface: IpContext
      Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
      Specified by:
      remoteCertificates in interface IpContext
    • flowControl

      public FlowControl flowControl()
      Description copied from interface: FlowContext
      Returns the current FlowControl state of the underlying network channel.
      Specified by:
      flowControl in interface FlowContext
    • flowControl

      public void flowControl(FlowControl flowControl)
      Description copied from interface: FlowContext
      Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
      Specified by:
      flowControl in interface FlowContext
    • flowControl

      public FlowControl flowControl(FlowModifier flowModifier)
      Description copied from interface: FlowContext
      Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
      Specified by:
      flowControl in interface FlowContext
    • httpSettings

      public HttpSettings httpSettings()
      Specified by:
      httpSettings in interface HttpClientContext
    • doRequest

      public void doRequest(HttpRequester<?> requester)
      Specified by:
      doRequest in interface HttpClientContext
    • readResponse

      public void readResponse()
      Specified by:
      readResponse in interface HttpClientContext
    • become

      public void become(IpSocket socket)
      Specified by:
      become in interface HttpClientContext
    • close

      public void close()
      Specified by:
      close in interface HttpClientContext