Search in sources :

Example 1 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class Layer2Http1_1Handler method socketOpened.

public void socketOpened(FrontendSocketImpl socket, boolean isReadyForWrites) {
    Memento parseState = httpParser.prepareToParse();
    MarshalState marshalState = httpParser.prepareToMarshal();
    socket.setHttp1_1ParseState(parseState, marshalState);
//timeoutListener.connectionOpened(socket, isReadyForWrites);
}
Also used : Memento(org.webpieces.httpparser.api.Memento) MarshalState(org.webpieces.httpparser.api.MarshalState)

Example 2 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class Layer2Http1_1Handler method initialDataImpl.

public InitiationResult initialDataImpl(FrontendSocketImpl socket, ByteBuffer buf) {
    Memento state = parse(socket, buf);
    //IF we are receiving a preface, there will ONLY be ONE message AND leftover data
    InitiationResult result = checkForPreface(socket, state);
    if (result != null)
        return result;
    //if we get this far, we now know we are http1.1
    if (state.getParsedMessages().size() >= 0) {
        processHttp1Messages(socket, state).exceptionally(t -> logException(t));
        return new InitiationResult(InitiationStatus.HTTP1_1);
    }
    // we don't know yet(not enough data)
    return null;
}
Also used : Memento(org.webpieces.httpparser.api.Memento)

Example 3 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class Layer2Http1_1Handler method incomingData.

public void incomingData(FrontendSocketImpl socket, ByteBuffer buf) {
    Memento state = parse(socket, buf);
    CompletableFuture<Void> future = processHttp1Messages(socket, state);
//return the future
}
Also used : Memento(org.webpieces.httpparser.api.Memento)

Example 4 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class Layer2Http1_1Handler method parse.

private Memento parse(FrontendSocketImpl socket, ByteBuffer buf) {
    DataWrapper moreData = dataGen.wrapByteBuffer(buf);
    Memento state = socket.getHttp1_1ParseState();
    state = httpParser.parse(state, moreData);
    return state;
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) Memento(org.webpieces.httpparser.api.Memento)

Example 5 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class Layer2Http1_1Handler method processHttp1MessagesImpl.

private CompletableFuture<Void> processHttp1MessagesImpl(FrontendSocketImpl socket, Memento state) {
    List<HttpPayload> parsed = state.getParsedMessages();
    CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
    for (HttpPayload payload : parsed) {
        future = future.thenCompose(w -> {
            log.info("msg received=" + payload);
            return processCorrectly(socket, payload);
        });
    }
    return future.thenApply(w -> null);
}
Also used : Logger(org.webpieces.util.logging.Logger) MarshalState(org.webpieces.httpparser.api.MarshalState) PermitQueue(com.webpieces.util.locking.PermitQueue) Http2Translations(org.webpieces.frontend2.impl.translation.Http2Translations) HttpParser(org.webpieces.httpparser.api.HttpParser) CompletableFuture(java.util.concurrent.CompletableFuture) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload) ByteBuffer(java.nio.ByteBuffer) StreamListener(org.webpieces.frontend2.api.StreamListener) Http2HeaderName(com.webpieces.http2parser.api.dto.lib.Http2HeaderName) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) Memento(org.webpieces.httpparser.api.Memento) List(java.util.List) HttpStream(org.webpieces.frontend2.api.HttpStream) StreamWriter(com.webpieces.http2engine.api.StreamWriter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) Http2Request(com.webpieces.hpack.api.dto.Http2Request) DataWrapper(org.webpieces.data.api.DataWrapper) DataWrapperGenerator(org.webpieces.data.api.DataWrapperGenerator) LoggerFactory(org.webpieces.util.logging.LoggerFactory) HttpMessageType(org.webpieces.httpparser.api.dto.HttpMessageType) DataWrapperGeneratorFactory(org.webpieces.data.api.DataWrapperGeneratorFactory) DataFrame(com.webpieces.http2parser.api.dto.DataFrame) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload)

Aggregations

Memento (org.webpieces.httpparser.api.Memento)6 DataWrapper (org.webpieces.data.api.DataWrapper)3 ByteBuffer (java.nio.ByteBuffer)2 MarshalState (org.webpieces.httpparser.api.MarshalState)2 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)2 Http2Request (com.webpieces.hpack.api.dto.Http2Request)1 StreamWriter (com.webpieces.http2engine.api.StreamWriter)1 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)1 Http2HeaderName (com.webpieces.http2parser.api.dto.lib.Http2HeaderName)1 Http2Msg (com.webpieces.http2parser.api.dto.lib.Http2Msg)1 PermitQueue (com.webpieces.util.locking.PermitQueue)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)1 DataWrapperGeneratorFactory (org.webpieces.data.api.DataWrapperGeneratorFactory)1 HttpStream (org.webpieces.frontend2.api.HttpStream)1 StreamListener (org.webpieces.frontend2.api.StreamListener)1