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

com.firefly.client.http2.ClientHTTPHandler Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.client.http2;

import com.firefly.codec.http2.model.MetaData;
import com.firefly.codec.http2.model.MetaData.Request;
import com.firefly.codec.http2.model.MetaData.Response;
import com.firefly.codec.http2.stream.HTTPConnection;
import com.firefly.codec.http2.stream.HTTPHandler;
import com.firefly.codec.http2.stream.HTTPOutputStream;
import com.firefly.utils.function.Action4;
import com.firefly.utils.function.Action6;
import com.firefly.utils.function.Func4;
import com.firefly.utils.function.Func5;

import java.nio.ByteBuffer;

public interface ClientHTTPHandler extends HTTPHandler {

    void continueToSendData(MetaData.Request request, MetaData.Response response, HTTPOutputStream output,
                            HTTPConnection connection);

    class Adapter extends HTTPHandler.Adapter implements ClientHTTPHandler {

        protected Action4 continueToSendData;

        public ClientHTTPHandler.Adapter headerComplete(
                Func4 headerComplete) {
            this.headerComplete = headerComplete;
            return this;
        }

        public ClientHTTPHandler.Adapter content(
                Func5 content) {
            this.content = content;
            return this;
        }

        public ClientHTTPHandler.Adapter contentComplete(
                Func4 contentComplete) {
            this.contentComplete = contentComplete;
            return this;
        }

        public ClientHTTPHandler.Adapter messageComplete(
                Func4 messageComplete) {
            this.messageComplete = messageComplete;
            return this;
        }

        public ClientHTTPHandler.Adapter badMessage(
                Action6 badMessage) {
            this.badMessage = badMessage;
            return this;
        }

        public ClientHTTPHandler.Adapter earlyEOF(
                Action4 earlyEOF) {
            this.earlyEOF = earlyEOF;
            return this;
        }

        public ClientHTTPHandler.Adapter continueToSendData(
                Action4 continueToSendData) {
            this.continueToSendData = continueToSendData;
            return this;
        }

        @Override
        public void continueToSendData(Request request, Response response, HTTPOutputStream output,
                                       HTTPConnection connection) {
            if (continueToSendData != null) {
                continueToSendData.call(request, response, output, connection);
            }
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy