Package org.webpieces.httpclient11.impl
Class CatchResponseListener
- java.lang.Object
-
- org.webpieces.httpclient11.impl.CatchResponseListener
-
- All Implemented Interfaces:
HttpResponseListener
public class CatchResponseListener extends java.lang.Object implements HttpResponseListener
-
-
Constructor Summary
Constructors Constructor Description CatchResponseListener(HttpResponseListener listener, java.lang.String svrSocket)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfailure(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.
-
-
-
Constructor Detail
-
CatchResponseListener
public CatchResponseListener(HttpResponseListener listener, java.lang.String svrSocket)
-
-
Method Detail
-
incomingResponse
public java.util.concurrent.CompletableFuture<HttpDataWriter> incomingResponse(org.webpieces.httpparser.api.dto.HttpResponse resp, boolean isComplete)
Description copied from interface:HttpResponseListenerThis 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:
incomingResponsein interfaceHttpResponseListener- Parameters:
resp- The HttpResponse message including body if there is oneisComplete- false if the transfer encoding is chunked in which case incomingChunk will be called for each chunk coming
-
failure
public void failure(java.lang.Throwable e)
- Specified by:
failurein interfaceHttpResponseListener
-
-