top.jfunc.http.component.BaseHttpRequestExecutor Maven / Gradle / Ivy
package top.jfunc.http.component;
import top.jfunc.http.base.ContentCallback;
import top.jfunc.http.request.HttpRequest;
import java.io.IOException;
/**
* 保存一些必须的共用的属性
* @param 处理body的
* @param 获取响应的header和stream的
* @author xiongshiyan
*/
public abstract class BaseHttpRequestExecutor {
private HeaderHandler requestHeaderHandler;
private StreamExtractor responseStreamExtractor;
private HeaderExtractor responseHeaderExtractor;
protected BaseHttpRequestExecutor(HeaderHandler requestHeaderHandler,
StreamExtractor responseStreamExtractor,
HeaderExtractor responseHeaderExtractor) {
this.responseStreamExtractor = responseStreamExtractor;
this.responseHeaderExtractor = responseHeaderExtractor;
this.requestHeaderHandler = requestHeaderHandler;
}
protected void handleHeaders(CC requester , HttpRequest httpRequest) throws IOException {
getRequestHeaderHandler().configHeaders(requester , httpRequest);
}
protected void handleBody(CC requester , ContentCallback contentCallback, HttpRequest httpRequest) throws IOException {
if(null != contentCallback){
contentCallback.doWriteWith(requester);
}
}
public StreamExtractor getResponseStreamExtractor() {
return responseStreamExtractor;
}
public HeaderExtractor getResponseHeaderExtractor() {
return responseHeaderExtractor;
}
public HeaderHandler getRequestHeaderHandler() {
return requestHeaderHandler;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy