Search in sources :

Example 1 with Http2ToHttp11

use of org.webpieces.http2translations.api.Http2ToHttp11 in project webpieces by deanhiller.

the class Http11StreamImpl method process.

@Override
public XFuture<StreamWriter> process(Http2Response headers) {
    closeCheck(headers);
    HttpResponse response = Http2ToHttp11.translateResponse(headers);
    if (http2Request.getKnownMethod() == Http2Method.CONNECT) {
        // bytes so we don't care about parsing anymore(ie. SSL or http)..
        return write(response).thenApply(c -> new Http11ChunkedWriter(http1Req, http2Request));
    } else if (headers.isEndOfStream()) {
        validateHeader(response);
        remove(headers);
        return write(response).thenApply(w -> {
            permitQueue.releasePermit();
            return new NoWritesWriter();
        });
    } else if (contentLengthGreaterThanZero(headers)) {
        return write(response).thenApply(w -> new ContentLengthResponseWriter(headers));
    }
    return write(response).thenApply(c -> new Http11ChunkedWriter(http1Req, http2Request));
}
Also used : Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) HttpChunk(org.webpieces.httpparser.api.dto.HttpChunk) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) AtomicReference(java.util.concurrent.atomic.AtomicReference) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload) ByteBuffer(java.nio.ByteBuffer) HttpResponse(org.webpieces.httpparser.api.dto.HttpResponse) HttpStream(org.webpieces.frontend2.api.HttpStream) HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) StreamMsg(com.webpieces.http2.api.dto.lowlevel.lib.StreamMsg) Map(java.util.Map) DataWrapper(org.webpieces.data.api.DataWrapper) Http2Method(com.webpieces.http2.api.dto.lowlevel.Http2Method) HttpData(org.webpieces.httpparser.api.dto.HttpData) FrontendSocket(org.webpieces.frontend2.api.FrontendSocket) PermitQueue(org.webpieces.util.locking.PermitQueue) Header(org.webpieces.httpparser.api.common.Header) Logger(org.slf4j.Logger) HttpParser(org.webpieces.httpparser.api.HttpParser) CancelReason(com.webpieces.http2.api.dto.lowlevel.CancelReason) KnownHeaderName(org.webpieces.httpparser.api.common.KnownHeaderName) HttpLastChunk(org.webpieces.httpparser.api.dto.HttpLastChunk) Http2ToHttp11(org.webpieces.http2translations.api.Http2ToHttp11) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) XFuture(org.webpieces.util.futures.XFuture) StreamRef(com.webpieces.http2.api.streaming.StreamRef) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) StreamWriter(com.webpieces.http2.api.streaming.StreamWriter) Http2HeaderName(com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName) PushStreamHandle(com.webpieces.http2.api.streaming.PushStreamHandle) ResponseStream(org.webpieces.frontend2.api.ResponseStream) Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) HttpResponse(org.webpieces.httpparser.api.dto.HttpResponse)

Aggregations

Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)1 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)1 CancelReason (com.webpieces.http2.api.dto.lowlevel.CancelReason)1 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)1 Http2Method (com.webpieces.http2.api.dto.lowlevel.Http2Method)1 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)1 Http2HeaderName (com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName)1 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)1 StreamMsg (com.webpieces.http2.api.dto.lowlevel.lib.StreamMsg)1 PushStreamHandle (com.webpieces.http2.api.streaming.PushStreamHandle)1 StreamRef (com.webpieces.http2.api.streaming.StreamRef)1 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 FrontendSocket (org.webpieces.frontend2.api.FrontendSocket)1