use of org.webpieces.httpclient11.api.HttpDataWriter in project webpieces by deanhiller.
the class CompletableListener method incomingResponse.
@Override
public XFuture<HttpDataWriter> incomingResponse(HttpResponse resp, boolean isComplete) {
HttpFullResponse resp1 = new HttpFullResponse(resp, dataGen.emptyWrapper());
if (isComplete) {
future.complete(resp1);
return XFuture.completedFuture(new NullWriter());
}
response = resp1;
return XFuture.completedFuture(new DataWriterImpl());
}
use of org.webpieces.httpclient11.api.HttpDataWriter in project webpieces by deanhiller.
the class HttpSocketImpl method actuallySendRequest.
private HttpStreamRef actuallySendRequest(HttpRequest request, HttpResponseListener listener) {
HttpResponseListener l = new CatchResponseListener(listener, svrSocket);
ByteBuffer wrap = parser.marshalToByteBuffer(state, request);
isConnect = false;
if (request.getRequestLine().getMethod().getKnownStatus() == KnownHttpMethod.CONNECT)
isConnect = true;
// put this on the queue before the write to be completed from the listener below
responsesToComplete.offer(l);
boolean canSendChunks = false;
Header header = request.getHeaderLookupStruct().getHeader(KnownHeaderName.TRANSFER_ENCODING);
if (header != null && "chunked".equals(header.getValue()))
canSendChunks = true;
boolean canSendTheChunks = canSendChunks;
XFuture<HttpDataWriter> writer = channel.write(wrap).thenApply(v -> new HttpChunkWriterImpl(channel, parser, state, isConnect, canSendTheChunks));
return new MyStreamRefImpl(writer, request);
}
Aggregations