All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.webpieces.http2parser.impl.ContinuationMarshaller Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.webpieces.http2parser.impl;

import com.webpieces.http2parser.api.dto.Http2Continuation;
import com.webpieces.http2parser.api.dto.Http2Frame;
import org.webpieces.data.api.BufferPool;
import org.webpieces.data.api.DataWrapper;
import org.webpieces.data.api.DataWrapperGenerator;

import javax.xml.crypto.Data;
import java.util.Optional;

public class ContinuationMarshaller extends FrameMarshallerImpl {
    ContinuationMarshaller(BufferPool bufferPool, DataWrapperGenerator dataGen) {
        super(bufferPool, dataGen);
    }

    public byte marshalFlags(Http2Frame frame) {
        Http2Continuation castFrame = (Http2Continuation) frame;

        byte value = 0x0;
        if (castFrame.isEndHeaders()) value |= 0x4;
        return value;
    }

    public DataWrapper marshalPayload(Http2Frame frame) {
        Http2Continuation castFrame = (Http2Continuation) frame;
        return castFrame.getHeaderBlock().serialize();
    }

    public void unmarshalFlagsAndPayload(Http2Frame frame, byte flags, Optional maybePayload) {
        Http2Continuation castFrame = (Http2Continuation) frame;

        castFrame.setEndHeaders((flags & 0x4) == 0x4);

        maybePayload.ifPresent(payload -> castFrame.getHeaderBlock().deserialize(payload));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy