Search in sources :

Example 21 with DataFrame

use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.

the class Level6LocalFlowControl method fireDataToClient.

public XFuture<Void> fireDataToClient(Stream stream, StreamMsg payload) {
    if (!(payload instanceof DataFrame))
        return notifyListener.sendPieceToApp(stream, payload);
    DataFrame f = (DataFrame) payload;
    long frameLength = f.getTransmitFrameLength();
    if (frameLength > connectionLocalWindowSize) {
        throw new ConnectionException(CancelReasonCode.FLOW_CONTROL_ERROR, logId, f.getStreamId(), "connectionLocalWindowSize too small=" + connectionLocalWindowSize + " frame len=" + frameLength + " for frame=" + f);
    } else if (frameLength > stream.getLocalWindowSize()) {
        throw new StreamException(CancelReasonCode.FLOW_CONTROL_ERROR, logId, f.getStreamId(), "connectionLocalWindowSize too small=" + connectionLocalWindowSize + " frame len=" + frameLength + " for frame=" + f);
    }
    totalSent += frameLength;
    connectionLocalWindowSize -= frameLength;
    stream.incrementLocalWindow(-frameLength);
    log.info("received framelen=" + frameLength + " newConnectionWindowSize=" + connectionLocalWindowSize + " streamSize=" + stream.getLocalWindowSize() + " totalSent=" + totalSent);
    return notifyListener.sendPieceToApp(stream, payload).thenApply(c -> updateFlowControl(frameLength, stream));
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException) StreamException(com.webpieces.http2.api.dto.error.StreamException)

Example 22 with DataFrame

use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.

the class Requests method createData.

public static DataFrame createData(int streamId, boolean eos) {
    DataFrame data = new DataFrame(streamId, eos);
    DataWrapper wrapByteArray = DATA_GEN.wrapByteArray(new byte[] { 2, 3 });
    data.setData(wrapByteArray);
    return data;
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame)

Example 23 with DataFrame

use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.

the class Requests method createBigData.

public static DataFrame createBigData(int streamId, boolean eos) {
    DataFrame data = new DataFrame(streamId, eos);
    String s = "hi there, this is a bit more data so that we can test a few things out";
    byte[] bytes = s.getBytes();
    DataWrapper wrapByteArray = DATA_GEN.wrapByteArray(bytes);
    data.setData(wrapByteArray);
    return data;
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame)

Example 24 with DataFrame

use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.

the class Http11ToHttp2 method translateChunk.

private static Http2Msg translateChunk(HttpChunk payload, boolean eos) {
    DataFrame frame = new DataFrame();
    frame.setData(payload.getBodyNonNull());
    frame.setEndOfStream(eos);
    return frame;
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame)

Example 25 with DataFrame

use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.

the class Http11ToHttp2 method translateData.

public static DataFrame translateData(HttpData payload) {
    DataFrame frame = new DataFrame();
    frame.setEndOfStream(payload.isEndOfData());
    frame.setData(payload.getBodyNonNull());
    return frame;
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame)

Aggregations

DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)52 Test (org.junit.Test)31 DataWrapper (org.webpieces.data.api.DataWrapper)28 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)19 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)13 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)11 MockResponseListener (org.webpieces.http2client.mock.MockResponseListener)9 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)9 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)8 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)8 MockStreamWriter (org.webpieces.http2client.mock.MockStreamWriter)7 StreamRef (com.webpieces.http2.api.streaming.StreamRef)6 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)6 ConnectionClosedException (com.webpieces.http2engine.api.error.ConnectionClosedException)5 Header (org.webpieces.httpparser.api.common.Header)5 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)4 HttpData (org.webpieces.httpparser.api.dto.HttpData)4 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)4 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)3 Http2Push (com.webpieces.http2.api.dto.highlevel.Http2Push)3