Class CompletableListener

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void failure​(java.lang.Throwable e)  
      java.util.concurrent.CompletableFuture<HttpDataWriter> incomingResponse​(org.webpieces.httpparser.api.dto.HttpResponse resp, boolean isComplete)
      This is sort of a hard api issue to solve.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompletableListener

        public CompletableListener​(java.util.concurrent.CompletableFuture<HttpFullResponse> future)
    • Method Detail

      • incomingResponse

        public java.util.concurrent.CompletableFuture<HttpDataWriter> incomingResponse​(org.webpieces.httpparser.api.dto.HttpResponse resp,
                                                                                       boolean isComplete)
        Description copied from interface: HttpResponseListener
        This is sort of a hard api issue to solve. When you send a request out to an http server for http 1.1, the server can do one of 3 things 1. send back a single response with no body 2. send back a response with a body (this body could be quite large) 3. send back a response, then send as many chunks as it wants followed by a last chunk(size=0) 4. send back a response, then infinitely stream chunks (some apis like twitter do this) This makes the callback api have a larger surface area than desired. The incomingResponse method will have isComplete=true in the cases of #1 or #2 above. In the case of #3, incomingChunk will be called over and over until the last chunk in which case isLastChunk will be set to true and the chunk will be of size 0, but the last chunk is special in that it can contain extra headers with it. NOTE: All HttpChunks can contain extensions as well. Those are included if they exist in the HttpChunk object
        Specified by:
        incomingResponse in interface HttpResponseListener
        Parameters:
        resp - The HttpResponse message including body if there is one
        isComplete - false if the transfer encoding is chunked in which case incomingChunk will be called for each chunk coming