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

org.zalando.logbook.netty.Offering Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
package org.zalando.logbook.netty;

import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpMessage;

import static io.netty.handler.codec.http.HttpUtil.getContentLength;
import static io.netty.handler.codec.http.LastHttpContent.EMPTY_LAST_CONTENT;

final class Offering implements State {

    @Override
    public State without() {
        return new Unbuffered();
    }

    @Override
    public State buffer(final HttpMessage message, final HttpContent content) {
        if (content.equals(EMPTY_LAST_CONTENT)) {
            // saves us from allocating an unnecessary buffer
            return this;
        }

        final int contentLength = getContentLength(message, 2048);
        return new Buffering(contentLength).buffer(message, content);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy