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);
}
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;
}
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
}
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;
}
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);
}
Aggregations