Search in sources :

Example 86 with Frame

use of org.eclipse.jetty.http2.frames.Frame in project jetty.project by eclipse.

the class HTTP2Stream method onData.

private void onData(DataFrame frame, Callback callback) {
    if (getRecvWindow() < 0) {
        // It's a bad client, it does not deserve to be
        // treated gently by just resetting the stream.
        session.close(ErrorCode.FLOW_CONTROL_ERROR.code, "stream_window_exceeded", Callback.NOOP);
        callback.failed(new IOException("stream_window_exceeded"));
        return;
    }
    // SPEC: remotely closed streams must be replied with a reset.
    if (isRemotelyClosed()) {
        reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), Callback.NOOP);
        callback.failed(new EOFException("stream_closed"));
        return;
    }
    if (isReset()) {
        // Just drop the frame.
        callback.failed(new IOException("stream_reset"));
        return;
    }
    if (updateClose(frame.isEndStream(), false))
        session.removeStream(this);
    notifyData(this, frame, callback);
}
Also used : EOFException(java.io.EOFException) ResetFrame(org.eclipse.jetty.http2.frames.ResetFrame) IOException(java.io.IOException)

Example 87 with Frame

use of org.eclipse.jetty.http2.frames.Frame in project jetty.project by eclipse.

the class SimpleFlowControlStrategy method onDataConsumed.

@Override
public void onDataConsumed(ISession session, IStream stream, int length) {
    if (length <= 0)
        return;
    // This is the simple algorithm for flow control.
    // This method is called when a whole flow controlled frame has been consumed.
    // We send a WindowUpdate every time, even if the frame was very small.
    WindowUpdateFrame sessionFrame = new WindowUpdateFrame(0, length);
    session.updateRecvWindow(length);
    if (LOG.isDebugEnabled())
        LOG.debug("Data consumed, increased session recv window by {} for {}", length, session);
    Frame[] streamFrame = Frame.EMPTY_ARRAY;
    if (stream != null) {
        if (stream.isClosed()) {
            if (LOG.isDebugEnabled())
                LOG.debug("Data consumed, ignoring update stream recv window by {} for closed {}", length, stream);
        } else {
            streamFrame = new Frame[1];
            streamFrame[0] = new WindowUpdateFrame(stream.getId(), length);
            stream.updateRecvWindow(length);
            if (LOG.isDebugEnabled())
                LOG.debug("Data consumed, increased stream recv window by {} for {}", length, stream);
        }
    }
    session.frames(stream, Callback.NOOP, sessionFrame, streamFrame);
}
Also used : WindowUpdateFrame(org.eclipse.jetty.http2.frames.WindowUpdateFrame) WindowUpdateFrame(org.eclipse.jetty.http2.frames.WindowUpdateFrame) Frame(org.eclipse.jetty.http2.frames.Frame)

Example 88 with Frame

use of org.eclipse.jetty.http2.frames.Frame in project jetty.project by eclipse.

the class HeadersBodyParser method onHeaders.

private void onHeaders(int parentStreamId, int weight, boolean exclusive, MetaData metaData) {
    PriorityFrame priorityFrame = null;
    if (hasFlag(Flags.PRIORITY))
        priorityFrame = new PriorityFrame(getStreamId(), parentStreamId, weight, exclusive);
    HeadersFrame frame = new HeadersFrame(getStreamId(), metaData, priorityFrame, isEndStream());
    notifyHeaders(frame);
}
Also used : PriorityFrame(org.eclipse.jetty.http2.frames.PriorityFrame) HeadersFrame(org.eclipse.jetty.http2.frames.HeadersFrame)

Example 89 with Frame

use of org.eclipse.jetty.http2.frames.Frame in project jetty.project by eclipse.

the class PriorityBodyParser method onPriority.

private boolean onPriority(int parentStreamId, int weight, boolean exclusive) {
    PriorityFrame frame = new PriorityFrame(getStreamId(), parentStreamId, weight, exclusive);
    reset();
    notifyPriority(frame);
    return true;
}
Also used : PriorityFrame(org.eclipse.jetty.http2.frames.PriorityFrame)

Example 90 with Frame

use of org.eclipse.jetty.http2.frames.Frame in project jetty.project by eclipse.

the class PushPromiseBodyParser method onPushPromise.

private void onPushPromise(int streamId, MetaData metaData) {
    PushPromiseFrame frame = new PushPromiseFrame(getStreamId(), streamId, metaData);
    notifyPushPromise(frame);
}
Also used : PushPromiseFrame(org.eclipse.jetty.http2.frames.PushPromiseFrame)

Aggregations

Test (org.junit.Test)124 HttpFields (org.eclipse.jetty.http.HttpFields)107 MetaData (org.eclipse.jetty.http.MetaData)107 HeadersFrame (org.eclipse.jetty.http2.frames.HeadersFrame)107 CountDownLatch (java.util.concurrent.CountDownLatch)104 Stream (org.eclipse.jetty.http2.api.Stream)99 Session (org.eclipse.jetty.http2.api.Session)94 ServerSessionListener (org.eclipse.jetty.http2.api.server.ServerSessionListener)85 FuturePromise (org.eclipse.jetty.util.FuturePromise)69 DataFrame (org.eclipse.jetty.http2.frames.DataFrame)60 ByteBuffer (java.nio.ByteBuffer)59 Callback (org.eclipse.jetty.util.Callback)53 HttpServletResponse (javax.servlet.http.HttpServletResponse)51 Promise (org.eclipse.jetty.util.Promise)49 ByteBufferPool (org.eclipse.jetty.io.ByteBufferPool)43 HTTP2Session (org.eclipse.jetty.http2.HTTP2Session)39 IOException (java.io.IOException)38 HttpServletRequest (javax.servlet.http.HttpServletRequest)38 ServletException (javax.servlet.ServletException)35 HashMap (java.util.HashMap)34