Class HttpConversation

    • Constructor Detail

      • HttpConversation

        public HttpConversation()
    • Method Detail

      • getExchanges

        public java.util.Deque<HttpExchange> getExchanges()
      • getResponseListeners

        public java.util.List<Response.ResponseListener> getResponseListeners()
        Returns the list of response listeners that needs to be notified of response events. This list changes as the conversation proceeds, as follows:
        1. request R1 send => conversation.updateResponseListeners(null)
          • exchanges in conversation: E1
          • listeners to be notified: E1.listeners
        2. response R1 arrived, 401 => conversation.updateResponseListeners(AuthenticationProtocolHandler.listener)
          • exchanges in conversation: E1
          • listeners to be notified: AuthenticationProtocolHandler.listener
        3. request R2 send => conversation.updateResponseListeners(null)
          • exchanges in conversation: E1 + E2
          • listeners to be notified: E2.listeners + E1.listeners
        4. response R2 arrived, 302 => conversation.updateResponseListeners(RedirectProtocolHandler.listener)
          • exchanges in conversation: E1 + E2
          • listeners to be notified: E2.listeners + RedirectProtocolHandler.listener
        5. request R3 send => conversation.updateResponseListeners(null)
          • exchanges in conversation: E1 + E2 + E3
          • listeners to be notified: E3.listeners + E1.listeners
        6. response R3 arrived, 200 => conversation.updateResponseListeners(null)
          • exchanges in conversation: E1 + E2 + E3
          • listeners to be notified: E3.listeners + E1.listeners
        Basically the override conversation listener replaces the first exchange response listener, and we also notify the last exchange response listeners (if it's not also the first). This scheme allows for protocol handlers to not worry about other protocol handlers, or to worry too much about notifying the first exchange response listeners, but still allowing a protocol handler to perform completion activities while another protocol handler performs new ones (as an example, the AuthenticationProtocolHandler stores the successful authentication credentials while the RedirectProtocolHandler performs a redirect).
        Returns:
        the list of response listeners that needs to be notified of response events
      • updateResponseListeners

        public void updateResponseListeners​(Response.ResponseListener overrideListener)
        Requests to update the response listener, eventually using the given override response listener, that must be notified instead of the first exchange response listeners. This works in conjunction with getResponseListeners(), returning the appropriate response listeners that needs to be notified of response events.
        Parameters:
        overrideListener - the override response listener
      • getTimeout

        public long getTimeout()

        Returns the total timeout for the conversation.

        The conversation total timeout is the total timeout of the first request in the conversation.

        Returns:
        the total timeout of the conversation
        See Also:
        Request.getTimeout()
      • abort

        public boolean abort​(java.lang.Throwable cause)