Search in sources :

Example 1 with HttpDataWriter

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());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse)

Example 2 with HttpDataWriter

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);
}
Also used : Header(org.webpieces.httpparser.api.common.Header) HttpDataWriter(org.webpieces.httpclient11.api.HttpDataWriter) ByteBuffer(java.nio.ByteBuffer) HttpResponseListener(org.webpieces.httpclient11.api.HttpResponseListener)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 HttpDataWriter (org.webpieces.httpclient11.api.HttpDataWriter)1 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)1 HttpResponseListener (org.webpieces.httpclient11.api.HttpResponseListener)1 Header (org.webpieces.httpparser.api.common.Header)1