Search in sources :

Example 1 with BadPayloadException

use of org.eclipse.jetty.websocket.api.BadPayloadException in project jetty.project by eclipse.

the class DeflateFrameExtension method incomingFrame.

@Override
public void incomingFrame(Frame frame) {
    if (frame.getType().isControl() || !frame.isRsv1() || !frame.hasPayload()) {
        nextIncomingFrame(frame);
        return;
    }
    try {
        ByteAccumulator accumulator = newByteAccumulator();
        decompress(accumulator, frame.getPayload());
        decompress(accumulator, TAIL_BYTES_BUF.slice());
        forwardIncoming(frame, accumulator);
    } catch (DataFormatException e) {
        throw new BadPayloadException(e);
    }
}
Also used : DataFormatException(java.util.zip.DataFormatException) BadPayloadException(org.eclipse.jetty.websocket.api.BadPayloadException)

Example 2 with BadPayloadException

use of org.eclipse.jetty.websocket.api.BadPayloadException in project jetty.project by eclipse.

the class PerMessageDeflateExtension method incomingFrame.

@Override
public void incomingFrame(Frame frame) {
    // Subsequent continuation frames don't have RSV1 set, but are compressed.
    if (frame.getType().isData()) {
        incomingCompressed = frame.isRsv1();
    }
    if (OpCode.isControlFrame(frame.getOpCode()) || !incomingCompressed) {
        nextIncomingFrame(frame);
        return;
    }
    ByteAccumulator accumulator = newByteAccumulator();
    try {
        ByteBuffer payload = frame.getPayload();
        decompress(accumulator, payload);
        if (frame.isFin()) {
            decompress(accumulator, TAIL_BYTES_BUF.slice());
        }
        forwardIncoming(frame, accumulator);
    } catch (DataFormatException e) {
        throw new BadPayloadException(e);
    }
    if (frame.isFin())
        incomingCompressed = false;
}
Also used : DataFormatException(java.util.zip.DataFormatException) BadPayloadException(org.eclipse.jetty.websocket.api.BadPayloadException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

DataFormatException (java.util.zip.DataFormatException)2 BadPayloadException (org.eclipse.jetty.websocket.api.BadPayloadException)2 ByteBuffer (java.nio.ByteBuffer)1