All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.firefly.codec.http2.stream.HTTPHandler Maven / Gradle / Ivy
package com.firefly.codec.http2.stream;
import java.nio.ByteBuffer;
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.utils.function.Action4;
import com.firefly.utils.function.Action6;
import com.firefly.utils.function.Func4;
import com.firefly.utils.function.Func5;
public interface HTTPHandler {
public boolean content(ByteBuffer item, MetaData.Request request, MetaData.Response response,
HTTPOutputStream output, HTTPConnection connection);
public boolean headerComplete(MetaData.Request request, MetaData.Response response, HTTPOutputStream output,
HTTPConnection connection);
public boolean messageComplete(MetaData.Request request, MetaData.Response response, HTTPOutputStream output,
HTTPConnection connection);
public void badMessage(int status, String reason, MetaData.Request request, MetaData.Response response,
HTTPOutputStream output, HTTPConnection connection);
public void earlyEOF(MetaData.Request request, MetaData.Response response, HTTPOutputStream output,
HTTPConnection connection);
public static class Adapter implements HTTPHandler {
protected Func4 messageComplete;
protected Func4 headerComplete;
protected Func5 content;
protected Action6 badMessage;
protected Action4 earlyEOF;
@Override
public boolean content(ByteBuffer item, Request request, Response response, HTTPOutputStream output,
HTTPConnection connection) {
if (content != null) {
return content.call(item, request, response, output, connection);
} else {
return false;
}
}
@Override
public boolean headerComplete(Request request, Response response, HTTPOutputStream output,
HTTPConnection connection) {
if (headerComplete != null) {
return headerComplete.call(request, response, output, connection);
} else {
return false;
}
}
@Override
public boolean messageComplete(Request request, Response response, HTTPOutputStream output,
HTTPConnection connection) {
if (messageComplete != null) {
return messageComplete.call(request, response, output, connection);
} else {
return true;
}
}
@Override
public void badMessage(int status, String reason, Request request, Response response, HTTPOutputStream output,
HTTPConnection connection) {
if (badMessage != null) {
badMessage.call(status, reason, request, response, output, connection);
}
}
@Override
public void earlyEOF(Request request, Response response, HTTPOutputStream output, HTTPConnection connection) {
if (earlyEOF != null) {
earlyEOF.call(request, response, output, connection);
}
}
}
}