add router task to release buffers after routing, refactor HTTP server API into application, domain, service subpackages
This commit is contained in:
parent
5c52f5149e
commit
fc1beabb58
125 changed files with 587 additions and 640 deletions
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = net-http
|
||||
version = 3.0.5
|
||||
version = 3.1.0
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
|
@ -6,11 +6,11 @@ import org.xbib.config.ConfigLoader;
|
|||
import org.xbib.config.ConfigLogger;
|
||||
import org.xbib.config.ConfigParams;
|
||||
import org.xbib.config.SystemConfigLogger;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.BaseApplicationModule;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.application.BaseApplicationModule;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.HttpService;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
public class ConfigApplicationModule extends BaseApplicationModule {
|
||||
|
|
|
@ -4,11 +4,11 @@ import org.xbib.jdbc.connection.pool.PoolConfig;
|
|||
import org.xbib.jdbc.connection.pool.PoolDataSource;
|
||||
import org.xbib.jdbc.query.DatabaseProvider;
|
||||
import org.xbib.jdbc.query.Flavor;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.BaseApplicationModule;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.application.BaseApplicationModule;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.HttpService;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
|
|
@ -14,10 +14,10 @@ import org.xbib.net.http.HttpHeaderNames;
|
|||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpSecurityDomain;
|
||||
import org.xbib.net.http.server.HttpSecurityDomain;
|
||||
import org.xbib.net.http.server.HttpService;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.domain.BaseHttpSecurityDomain;
|
||||
import org.xbib.net.http.server.domain.HttpSecurityDomain;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import org.xbib.net.http.server.auth.BasicAuthenticationHandler;
|
||||
import org.xbib.net.http.server.auth.FormAuthenticationHandler;
|
||||
import org.xbib.net.http.server.ldap.LdapContextFactory;
|
||||
|
@ -25,7 +25,7 @@ import org.xbib.net.http.server.ldap.LdapGroupMapping;
|
|||
import org.xbib.net.http.server.ldap.LdapRealm;
|
||||
import org.xbib.net.http.server.ldap.LdapUserMapping;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.buffer.NettyDataBufferFactory;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsAddress;
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.nio.file.Paths;
|
|||
import java.time.Duration;
|
||||
|
||||
import org.xbib.net.http.cookie.SameSite;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.xbib.net.http.server.application.web;
|
||||
|
||||
import org.xbib.net.http.server.BaseApplicationBuilder;
|
||||
import org.xbib.net.http.server.application.BaseApplicationBuilder;
|
||||
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Optional;
|
|||
import java.util.ServiceLoader;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
import org.xbib.net.http.server.HttpDomain;
|
||||
import org.xbib.net.http.server.domain.HttpDomain;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.xbib.net.http.client.netty.HttpRequest;
|
|||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.client.netty.secure.NettyHttpsClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsAddress;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsRequest;
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.xbib.net.http.client.netty.HttpRequest;
|
|||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.client.netty.secure.NettyHttpsClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsAddress;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsRequest;
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.xbib.net.http.client.netty.HttpRequest;
|
|||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.client.netty.secure.NettyHttpsClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsAddress;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsRequest;
|
||||
|
|
|
@ -20,14 +20,14 @@ import org.xbib.net.http.client.netty.HttpRequest;
|
|||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.client.netty.secure.NettyHttpsClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsAddress;
|
||||
import org.xbib.net.http.server.netty.secure.HttpsRequest;
|
||||
import org.xbib.net.http.server.netty.secure.NettyHttpsServerConfig;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.xbib.net.http.HttpMethod;
|
|||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.BaseHttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
|
@ -116,7 +115,7 @@ public class HttpRequestBuilder extends BaseHttpRequestBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void release() {
|
||||
if (fullHttpRequest != null) {
|
||||
logger.log(Level.FINER, "releasing retained netty request");
|
||||
fullHttpRequest.release();
|
||||
|
|
|
@ -3,13 +3,9 @@ package org.xbib.net.http.server.netty;
|
|||
import org.xbib.net.http.server.BaseHttpResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class HttpResponse extends BaseHttpResponse {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(HttpResponse.class.getName());
|
||||
|
||||
private final HttpResponseBuilder builder;
|
||||
|
||||
protected HttpResponse(HttpResponseBuilder builder) {
|
||||
|
@ -23,7 +19,7 @@ public class HttpResponse extends BaseHttpResponse {
|
|||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
builder.close();
|
||||
builder.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -129,8 +129,9 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (ctx.channel().isOpen()) {
|
||||
public void release() {
|
||||
super.release();
|
||||
if (ctx != null && ctx.channel().isOpen()) {
|
||||
logger.log(Level.FINER, "closing netty channel " + ctx.channel());
|
||||
ctx.close();
|
||||
}
|
||||
|
@ -185,7 +186,6 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
}
|
||||
HttpHeaders trailingHeaders = new DefaultHttpHeaders();
|
||||
super.trailingHeaders.entries().forEach(e -> trailingHeaders.add(e.getKey(), e.getValue()));
|
||||
// retain Netty byteBuf because FullHttpResponse will be released in writeAndFlush()
|
||||
FullHttpResponse fullHttpResponse = new DefaultFullHttpResponse(HttpVersion.valueOf(version.text()),
|
||||
responseStatus, byteBuf.retain(), headers, trailingHeaders);
|
||||
if (!ctx.channel().isWritable()) {
|
||||
|
@ -204,7 +204,7 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
|
||||
private void internalWrite(FileChannel fileChannel, int bufferSize, boolean keepAlive) {
|
||||
if (!ctx.channel().isWritable()) {
|
||||
logger.log(Level.WARNING, "we have a problem, the channel " + ctx.channel() + " is not writable");
|
||||
logger.log(Level.WARNING, "channel not writeable: " + ctx.channel());
|
||||
}
|
||||
HttpResponseStatus responseStatus = HttpResponseStatus.valueOf(status.code());
|
||||
DefaultHttpResponse rsp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, responseStatus);
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.xbib.net.NetworkClass;
|
|||
import org.xbib.net.NetworkUtils;
|
||||
import org.xbib.net.SocketConfig;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.HttpServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -5,7 +5,7 @@ import io.netty.channel.EventLoopGroup;
|
|||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.HttpServerBuilder;
|
||||
import org.xbib.net.util.NamedThreadFactory;
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import io.netty.buffer.ByteBuf;
|
|||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.PooledDataBuffer;
|
||||
|
||||
|
@ -21,11 +23,12 @@ import org.xbib.net.buffer.PooledDataBuffer;
|
|||
*/
|
||||
public class NettyDataBuffer implements PooledDataBuffer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(NettyDataBuffer.class.getName());
|
||||
|
||||
private final ByteBuf byteBuf;
|
||||
|
||||
private final NettyDataBufferFactory dataBufferFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code NettyDataBuffer} based on the given {@code ByteBuff}.
|
||||
* @param byteBuf the buffer to base this buffer on
|
||||
|
@ -37,18 +40,17 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
this.dataBufferFactory = dataBufferFactory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Directly exposes the native {@code ByteBuf} that this buffer is based on.
|
||||
* @return the wrapped byte buffer
|
||||
*/
|
||||
public ByteBuf getNativeBuffer() {
|
||||
return this.byteBuf;
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBufferFactory factory() {
|
||||
return this.dataBufferFactory;
|
||||
return dataBufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,11 +59,11 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
if (fromIndex < 0) {
|
||||
fromIndex = 0;
|
||||
}
|
||||
else if (fromIndex >= this.byteBuf.writerIndex()) {
|
||||
else if (fromIndex >= byteBuf.writerIndex()) {
|
||||
return -1;
|
||||
}
|
||||
int length = this.byteBuf.writerIndex() - fromIndex;
|
||||
return this.byteBuf.forEachByte(fromIndex, length, predicate.negate()::test);
|
||||
int length = byteBuf.writerIndex() - fromIndex;
|
||||
return byteBuf.forEachByte(fromIndex, length, predicate.negate()::test);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,96 +72,96 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
if (fromIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
fromIndex = Math.min(fromIndex, this.byteBuf.writerIndex() - 1);
|
||||
return this.byteBuf.forEachByteDesc(0, fromIndex + 1, predicate.negate()::test);
|
||||
fromIndex = Math.min(fromIndex, byteBuf.writerIndex() - 1);
|
||||
return byteBuf.forEachByteDesc(0, fromIndex + 1, predicate.negate()::test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readableByteCount() {
|
||||
return this.byteBuf.readableBytes();
|
||||
return byteBuf.readableBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writableByteCount() {
|
||||
return this.byteBuf.writableBytes();
|
||||
return byteBuf.writableBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readPosition() {
|
||||
return this.byteBuf.readerIndex();
|
||||
return byteBuf.readerIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer readPosition(int readPosition) {
|
||||
this.byteBuf.readerIndex(readPosition);
|
||||
byteBuf.readerIndex(readPosition);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writePosition() {
|
||||
return this.byteBuf.writerIndex();
|
||||
return byteBuf.writerIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer writePosition(int writePosition) {
|
||||
this.byteBuf.writerIndex(writePosition);
|
||||
byteBuf.writerIndex(writePosition);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return this.byteBuf.getByte(index);
|
||||
return byteBuf.getByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return this.byteBuf.capacity();
|
||||
return byteBuf.capacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer capacity(int capacity) {
|
||||
this.byteBuf.capacity(capacity);
|
||||
byteBuf.capacity(capacity);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBuffer ensureCapacity(int capacity) {
|
||||
this.byteBuf.ensureWritable(capacity);
|
||||
byteBuf.ensureWritable(capacity);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte read() {
|
||||
return this.byteBuf.readByte();
|
||||
return byteBuf.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer read(byte[] destination) {
|
||||
this.byteBuf.readBytes(destination);
|
||||
byteBuf.readBytes(destination);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer read(byte[] destination, int offset, int length) {
|
||||
this.byteBuf.readBytes(destination, offset, length);
|
||||
byteBuf.readBytes(destination, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer write(byte b) {
|
||||
this.byteBuf.writeByte(b);
|
||||
byteBuf.writeByte(b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer write(byte[] source) {
|
||||
this.byteBuf.writeBytes(source);
|
||||
byteBuf.writeBytes(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer write(byte[] source, int offset, int length) {
|
||||
this.byteBuf.writeBytes(source, offset, length);
|
||||
byteBuf.writeBytes(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -177,7 +179,6 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
ByteBuffer[] byteBuffers = new ByteBuffer[buffers.length];
|
||||
for (int i = 0; i < buffers.length; i++) {
|
||||
byteBuffers[i] = buffers[i].asByteBuffer();
|
||||
|
||||
}
|
||||
write(byteBuffers);
|
||||
}
|
||||
|
@ -196,9 +197,9 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
|
||||
@Override
|
||||
public NettyDataBuffer write(ByteBuffer... buffers) {
|
||||
if (buffers != null && buffers.length > 0) {
|
||||
if (buffers != null) {
|
||||
for (ByteBuffer buffer : buffers) {
|
||||
this.byteBuf.writeBytes(buffer);
|
||||
byteBuf.writeBytes(buffer);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
@ -211,9 +212,9 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
* @return this buffer
|
||||
*/
|
||||
public NettyDataBuffer write(ByteBuf... byteBufs) {
|
||||
if (byteBufs != null && byteBufs.length > 0) {
|
||||
if (byteBufs != null) {
|
||||
for (ByteBuf byteBuf : byteBufs) {
|
||||
this.byteBuf.writeBytes(byteBuf);
|
||||
byteBuf.writeBytes(byteBuf);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
@ -224,10 +225,10 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
Objects.requireNonNull(charSequence, "CharSequence must not be null");
|
||||
Objects.requireNonNull(charset, "Charset must not be null");
|
||||
if (StandardCharsets.UTF_8.equals(charset)) {
|
||||
ByteBufUtil.writeUtf8(this.byteBuf, charSequence);
|
||||
ByteBufUtil.writeUtf8(byteBuf, charSequence);
|
||||
}
|
||||
else if (StandardCharsets.US_ASCII.equals(charset)) {
|
||||
ByteBufUtil.writeAscii(this.byteBuf, charSequence);
|
||||
ByteBufUtil.writeAscii(byteBuf, charSequence);
|
||||
}
|
||||
else {
|
||||
return PooledDataBuffer.super.write(charSequence, charset);
|
||||
|
@ -237,88 +238,88 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
|
||||
@Override
|
||||
public NettyDataBuffer slice(int index, int length) {
|
||||
ByteBuf slice = this.byteBuf.slice(index, length);
|
||||
return new NettyDataBuffer(slice, this.dataBufferFactory);
|
||||
ByteBuf slice = byteBuf.slice(index, length);
|
||||
return new NettyDataBuffer(slice, dataBufferFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer retainedSlice(int index, int length) {
|
||||
ByteBuf slice = this.byteBuf.retainedSlice(index, length);
|
||||
return new NettyDataBuffer(slice, this.dataBufferFactory);
|
||||
ByteBuf slice = byteBuf.retainedSlice(index, length);
|
||||
return new NettyDataBuffer(slice, dataBufferFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer asByteBuffer() {
|
||||
return this.byteBuf.nioBuffer();
|
||||
return byteBuf.nioBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer asByteBuffer(int index, int length) {
|
||||
return this.byteBuf.nioBuffer(index, length);
|
||||
return byteBuf.nioBuffer(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream asInputStream() {
|
||||
return new ByteBufInputStream(this.byteBuf);
|
||||
return new ByteBufInputStream(byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream asInputStream(boolean releaseOnClose) {
|
||||
return new ByteBufInputStream(this.byteBuf, releaseOnClose);
|
||||
return new ByteBufInputStream(byteBuf, releaseOnClose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream asOutputStream() {
|
||||
return new ByteBufOutputStream(this.byteBuf);
|
||||
return new ByteBufOutputStream(byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Charset charset) {
|
||||
Objects.requireNonNull(charset, "Charset must not be null");
|
||||
return this.byteBuf.toString(charset);
|
||||
return byteBuf.toString(charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(int index, int length, Charset charset) {
|
||||
Objects.requireNonNull(charset, "Charset must not be null");
|
||||
return this.byteBuf.toString(index, length, charset);
|
||||
return byteBuf.toString(index, length, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllocated() {
|
||||
return this.byteBuf.refCnt() > 0;
|
||||
return byteBuf.refCnt() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PooledDataBuffer retain() {
|
||||
return new NettyDataBuffer(this.byteBuf.retain(), this.dataBufferFactory);
|
||||
return new NettyDataBuffer(byteBuf.retain(), dataBufferFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PooledDataBuffer touch(Object hint) {
|
||||
this.byteBuf.touch(hint);
|
||||
byteBuf.touch(hint);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release() {
|
||||
return this.byteBuf.release();
|
||||
public void release() {
|
||||
boolean deallocated = byteBuf.release();
|
||||
logger.log(Level.FINEST, "released " + byteBuf + " deallocated = " + deallocated);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof NettyDataBuffer &&
|
||||
this.byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
|
||||
byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.byteBuf.hashCode();
|
||||
return byteBuf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.byteBuf.toString();
|
||||
return byteBuf.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,18 +44,18 @@ public class NettyDataBufferFactory implements DataBufferFactory {
|
|||
* Return the {@code ByteBufAllocator} used by this factory.
|
||||
*/
|
||||
public ByteBufAllocator getByteBufAllocator() {
|
||||
return this.byteBufAllocator;
|
||||
return byteBufAllocator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer allocateBuffer() {
|
||||
ByteBuf byteBuf = this.byteBufAllocator.buffer();
|
||||
ByteBuf byteBuf = byteBufAllocator.buffer();
|
||||
return new NettyDataBuffer(byteBuf, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NettyDataBuffer allocateBuffer(int initialCapacity) {
|
||||
ByteBuf byteBuf = this.byteBufAllocator.buffer(initialCapacity);
|
||||
ByteBuf byteBuf = byteBufAllocator.buffer(initialCapacity);
|
||||
return new NettyDataBuffer(byteBuf, this);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class NettyDataBufferFactory implements DataBufferFactory {
|
|||
if (bufferCount == 1) {
|
||||
return dataBuffers.get(0);
|
||||
}
|
||||
CompositeByteBuf composite = this.byteBufAllocator.compositeBuffer(bufferCount);
|
||||
CompositeByteBuf composite = byteBufAllocator.compositeBuffer(bufferCount);
|
||||
for (DataBuffer dataBuffer : dataBuffers) {
|
||||
if (!(dataBuffer instanceof NettyDataBuffer)) {
|
||||
throw new IllegalArgumentException("dataBuffer");
|
||||
|
@ -112,8 +112,7 @@ public class NettyDataBufferFactory implements DataBufferFactory {
|
|||
* @return the netty {@code ByteBuf}
|
||||
*/
|
||||
public static ByteBuf toByteBuf(DataBuffer buffer) {
|
||||
if (buffer instanceof NettyDataBuffer) {
|
||||
NettyDataBuffer nettyDataBuffer = (NettyDataBuffer) buffer;
|
||||
if (buffer instanceof NettyDataBuffer nettyDataBuffer) {
|
||||
return nettyDataBuffer.getNativeBuffer();
|
||||
}
|
||||
else {
|
||||
|
@ -123,6 +122,6 @@ public class NettyDataBufferFactory implements DataBufferFactory {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NettyDataBufferFactory (" + this.byteBufAllocator + ")";
|
||||
return "NettyDataBufferFactory (" + byteBufAllocator + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.xbib.net.http.HttpVersion;
|
|||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.xbib.net.http.HttpVersion;
|
|||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.xbib.net.http.HttpResponseStatus;
|
|||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.xbib.net.http.HttpVersion;
|
|||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
|
|
|
@ -13,10 +13,10 @@ import org.xbib.net.http.HttpResponseStatus;
|
|||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServer;
|
||||
import org.xbib.net.http.server.netty.NettyHttpServerConfig;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.xbib.net.http.HttpMethod;
|
|||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.BaseHttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -99,6 +98,6 @@ public class HttpRequestBuilder extends BaseHttpRequestBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void release() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,6 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void release() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.xbib.net.http.HttpHeaderNames;
|
|||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.HttpServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.xbib.net.http.server.nio;
|
||||
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
|
||||
public class NioHttpServerBuilder {
|
||||
|
|
|
@ -7,9 +7,9 @@ import org.xbib.net.http.HttpAddress;
|
|||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
import org.xbib.net.http.server.nio.NioHttpServer;
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.xbib.net.NetworkClass;
|
|||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
import org.xbib.net.http.server.simple.SimpleHttpServer;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.xbib.net.http.HttpMethod;
|
|||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.BaseHttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
@ -100,7 +99,6 @@ public class HttpRequestBuilder extends BaseHttpRequestBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
|
||||
public void release() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,6 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
|
||||
public void release() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.xbib.net.NetworkUtils;
|
|||
import org.xbib.net.SocketConfig;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.xbib.net.http.server.simple;
|
||||
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
|
||||
public class SimpleHttpServerBuilder {
|
||||
|
|
|
@ -8,10 +8,10 @@ import org.xbib.net.http.HttpHeaderValues;
|
|||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.simple.HttpRequest;
|
||||
import org.xbib.net.http.server.simple.HttpRequestBuilder;
|
||||
import org.xbib.net.http.server.simple.HttpResponse;
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.xbib.net.http.HttpAddress;
|
|||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.BaseApplication;
|
||||
import org.xbib.net.http.server.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.application.BaseApplication;
|
||||
import org.xbib.net.http.server.domain.BaseHttpDomain;
|
||||
import org.xbib.net.http.server.route.BaseHttpRouter;
|
||||
import org.xbib.net.http.server.BaseHttpService;
|
||||
import org.xbib.net.http.server.service.BaseHttpService;
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
import org.xbib.net.http.server.resource.FileResourceHandler;
|
||||
import org.xbib.net.http.server.simple.SimpleHttpServer;
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import org.xbib.net.http.server.ApplicationModule;
|
||||
import org.xbib.net.http.server.application.ApplicationModule;
|
||||
|
||||
module org.xbib.net.http.server {
|
||||
uses ApplicationModule;
|
||||
uses org.xbib.config.ConfigLogger;
|
||||
exports org.xbib.net.http.server;
|
||||
exports org.xbib.net.http.server.application;
|
||||
exports org.xbib.net.http.server.auth;
|
||||
exports org.xbib.net.http.server.cookie;
|
||||
exports org.xbib.net.http.server.decorate;
|
||||
exports org.xbib.net.http.server.domain;
|
||||
exports org.xbib.net.http.server.handler;
|
||||
exports org.xbib.net.http.server.ldap;
|
||||
exports org.xbib.net.http.server.persist;
|
||||
|
@ -16,6 +18,7 @@ module org.xbib.net.http.server {
|
|||
exports org.xbib.net.http.server.resource;
|
||||
exports org.xbib.net.http.server.resource.negotiate;
|
||||
exports org.xbib.net.http.server.route;
|
||||
exports org.xbib.net.http.server.service;
|
||||
exports org.xbib.net.http.server.session;
|
||||
exports org.xbib.net.http.server.session.file;
|
||||
exports org.xbib.net.http.server.session.memory;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import org.xbib.net.http.server.auth.BaseAttributes;
|
||||
|
||||
public abstract class BaseHttpRequest implements HttpRequest {
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Objects;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.URLBuilder;
|
||||
|
@ -8,12 +13,6 @@ import org.xbib.net.http.HttpHeaders;
|
|||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class BaseHttpRequestBuilder implements HttpRequestBuilder {
|
||||
|
||||
protected HttpServerContext httpServerContext;
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.datastructures.common.Pair;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DataBufferFactory;
|
||||
import org.xbib.net.buffer.DefaultDataBufferFactory;
|
||||
import org.xbib.net.http.server.cookie.CookieEncoder;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
@ -24,6 +11,19 @@ import java.util.Locale;
|
|||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.datastructures.common.Pair;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DataBufferFactory;
|
||||
import org.xbib.net.buffer.DefaultDataBufferFactory;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.server.auth.BaseAttributes;
|
||||
import org.xbib.net.http.server.cookie.CookieEncoder;
|
||||
|
||||
public abstract class BaseHttpResponseBuilder implements HttpResponseBuilder {
|
||||
|
||||
|
@ -344,6 +344,14 @@ public abstract class BaseHttpResponseBuilder implements HttpResponseBuilder {
|
|||
logger.log(Level.FINER, "done");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
if (dataBuffer != null) {
|
||||
logger.log(Level.FINER, "databuffer release " + dataBuffer);
|
||||
dataBuffer.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void buildHeaders(long contentLength) {
|
||||
this.length = contentLength;
|
||||
if (!headers.containsHeader(HttpHeaderNames.CONTENT_TYPE)) {
|
||||
|
@ -373,7 +381,7 @@ public abstract class BaseHttpResponseBuilder implements HttpResponseBuilder {
|
|||
if (httpServerConfig != null && httpServerConfig.getServerName() != null) {
|
||||
headers.add(HttpHeaderNames.SERVER, httpServerConfig.getServerName());
|
||||
}
|
||||
logger.log(Level.FINER, "done: status = " + status + " headers = " + headers);
|
||||
logger.log(Level.FINER, "build headers: status = " + status + " headers = " + headers);
|
||||
}
|
||||
|
||||
public CharBuffer wrapHeaders() {
|
||||
|
|
|
@ -1,19 +1,5 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.util.Map;
|
||||
import org.xbib.datastructures.json.tiny.Json;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.cookie.CookieBox;
|
||||
import org.xbib.net.http.server.route.HttpRouteResolver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.CharBuffer;
|
||||
|
@ -24,10 +10,26 @@ import java.nio.charset.IllegalCharsetNameException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.xbib.datastructures.json.tiny.Json;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaderValues;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.cookie.CookieBox;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
import org.xbib.net.http.server.auth.BaseAttributes;
|
||||
import org.xbib.net.http.server.domain.HttpDomain;
|
||||
import org.xbib.net.http.server.route.HttpRouteResolver;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import static org.xbib.net.http.HttpHeaderNames.CONTENT_TYPE;
|
||||
|
||||
public class BaseHttpServerContext implements HttpServerContext {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class HttpException extends IOException {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.Request;
|
||||
|
@ -8,9 +10,6 @@ import org.xbib.net.http.HttpHeaders;
|
|||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface HttpRequest extends Request {
|
||||
|
||||
URL getServerURL();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
|
@ -7,11 +9,7 @@ import org.xbib.net.http.HttpHeaders;
|
|||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpVersion;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public interface HttpRequestBuilder extends Closeable {
|
||||
public interface HttpRequestBuilder {
|
||||
|
||||
HttpRequestBuilder setAddress(HttpAddress httpAddress);
|
||||
|
||||
|
@ -49,4 +47,6 @@ public interface HttpRequestBuilder extends Closeable {
|
|||
|
||||
void done();
|
||||
|
||||
void release();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.Response;
|
||||
|
||||
public interface HttpResponse extends Response {
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DataBufferFactory;
|
||||
|
@ -8,13 +12,7 @@ import org.xbib.net.http.HttpResponseStatus;
|
|||
import org.xbib.net.http.HttpVersion;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public interface HttpResponseBuilder extends Closeable {
|
||||
public interface HttpResponseBuilder {
|
||||
|
||||
HttpResponseBuilder setDataBufferFactory(DataBufferFactory dataBufferFactory);
|
||||
|
||||
|
@ -74,4 +72,6 @@ public interface HttpResponseBuilder extends Closeable {
|
|||
|
||||
void done();
|
||||
|
||||
void release();
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.xbib.net.http.server;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.BindException;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
|
||||
public interface HttpServer extends Closeable {
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.NetworkClass;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.xbib.net.NetworkClass;
|
||||
|
||||
public class HttpServerConfig {
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.http.server.route.HttpRouteResolver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.http.server.route.HttpRouteResolver;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public interface HttpServerContext {
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.xbib.net.http.server;
|
|||
|
||||
import org.xbib.net.ParameterDefinition;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.server.domain.HttpSecurityDomain;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public interface HttpServiceBuilder {
|
||||
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.session.SessionListener;
|
||||
import org.xbib.settings.Settings;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
@ -12,6 +7,14 @@ import java.time.ZoneId;
|
|||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpRequestBuilder;
|
||||
import org.xbib.net.http.server.HttpResponseBuilder;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.domain.HttpDomain;
|
||||
import org.xbib.net.http.server.session.SessionListener;
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
public interface Application extends SessionListener, Resolver<Path>, Closeable {
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
|
||||
public interface ApplicationBuilder {
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import org.xbib.net.http.server.session.Session;
|
||||
import org.xbib.settings.Settings;
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ApplicationThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
|
||||
private final Logger logger = Logger.getLogger(ApplicationThreadPoolExecutor.class.getName());
|
||||
|
||||
public ApplicationThreadPoolExecutor(int nThreads, int maxQueue,
|
||||
long keepAliveTime, TimeUnit timeUnit,
|
||||
ThreadFactory threadFactory) {
|
||||
super(nThreads, nThreads, keepAliveTime, timeUnit, createBlockingQueue(maxQueue), threadFactory);
|
||||
logger.log(Level.FINE, "threadpool executor up with nThreads = " + nThreads +
|
||||
" keepAliveTime = " + keepAliveTime +
|
||||
" time unit = " + timeUnit +
|
||||
" maxQueue = " + maxQueue +
|
||||
" threadFactory = " + threadFactory);
|
||||
}
|
||||
|
||||
private static BlockingQueue<Runnable> createBlockingQueue(int max) {
|
||||
return max == Integer.MAX_VALUE ? new SynchronousQueue<>(true) : new ArrayBlockingQueue<>(max);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
|
||||
return new RouterTask<>(callable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterExecute(Runnable runnable, Throwable terminationCause) {
|
||||
super.afterExecute(runnable, terminationCause);
|
||||
logger.log(Level.FINEST, "after execute of " + runnable);
|
||||
if (terminationCause != null) {
|
||||
logger.log(Level.SEVERE, terminationCause.getMessage(), terminationCause);
|
||||
return;
|
||||
}
|
||||
if (runnable instanceof RouterTask<?> routerTask) {
|
||||
RouterCallable routerCallable = (RouterCallable) routerTask.getCallable();
|
||||
logger.log(Level.FINEST, "release " + routerCallable);
|
||||
routerCallable.release();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,4 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.cookie.SameSite;
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.cookie.IncomingCookieHandler;
|
||||
import org.xbib.net.http.server.cookie.OutgoingCookieHandler;
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
import org.xbib.net.http.server.session.memory.MemoryPropertiesSessionCodec;
|
||||
import org.xbib.net.http.server.render.HttpResponseRenderer;
|
||||
import org.xbib.net.http.server.session.IncomingSessionHandler;
|
||||
import org.xbib.net.http.server.session.OutgoingSessionHandler;
|
||||
import org.xbib.net.http.server.session.Session;
|
||||
import org.xbib.net.http.server.util.BlockingThreadPoolExecutor;
|
||||
import org.xbib.net.http.server.validate.HttpRequestValidator;
|
||||
import org.xbib.net.util.NamedThreadFactory;
|
||||
import org.xbib.net.util.RandomUtil;
|
||||
import org.xbib.settings.Settings;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
@ -32,6 +14,29 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.cookie.SameSite;
|
||||
import org.xbib.net.http.server.BaseHttpServerContext;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpRequestBuilder;
|
||||
import org.xbib.net.http.server.HttpResponseBuilder;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.cookie.IncomingCookieHandler;
|
||||
import org.xbib.net.http.server.cookie.OutgoingCookieHandler;
|
||||
import org.xbib.net.http.server.domain.HttpDomain;
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
import org.xbib.net.http.server.render.HttpResponseRenderer;
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
import org.xbib.net.http.server.session.IncomingSessionHandler;
|
||||
import org.xbib.net.http.server.session.OutgoingSessionHandler;
|
||||
import org.xbib.net.http.server.session.Session;
|
||||
import org.xbib.net.http.server.session.memory.MemoryPropertiesSessionCodec;
|
||||
import org.xbib.net.http.server.validate.HttpRequestValidator;
|
||||
import org.xbib.net.util.NamedThreadFactory;
|
||||
import org.xbib.net.util.RandomUtil;
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
public class BaseApplication implements Application {
|
||||
|
||||
|
@ -39,7 +44,7 @@ public class BaseApplication implements Application {
|
|||
|
||||
protected BaseApplicationBuilder builder;
|
||||
|
||||
private final BlockingThreadPoolExecutor executor;
|
||||
private final ApplicationThreadPoolExecutor executor;
|
||||
|
||||
private final HttpRequestValidator httpRequestValidator;
|
||||
|
||||
|
@ -59,7 +64,7 @@ public class BaseApplication implements Application {
|
|||
|
||||
protected BaseApplication(BaseApplicationBuilder builder) {
|
||||
this.builder = builder;
|
||||
this.executor = new BlockingThreadPoolExecutor(builder.blockingThreadCount, builder.blockingThreadQueueCount,
|
||||
this.executor = new ApplicationThreadPoolExecutor(builder.blockingThreadCount, builder.blockingThreadQueueCount,
|
||||
builder.blockingThreadKeepAliveTime, builder.blockingThreadKeepAliveTimeUnit,
|
||||
new NamedThreadFactory("org-xbib-net-http-server-application"));
|
||||
this.executor.setRejectedExecutionHandler((runnable, threadPoolExecutor) ->
|
||||
|
@ -128,9 +133,21 @@ public class BaseApplication implements Application {
|
|||
@Override
|
||||
public void dispatch(HttpRequestBuilder httpRequestBuilder,
|
||||
HttpResponseBuilder httpResponseBuilder) {
|
||||
Submittable submittable = new Submittable(httpRequestBuilder, httpResponseBuilder);
|
||||
Future<?> future = executor.submit(submittable);
|
||||
logger.log(Level.FINE, "dispatching " + future);
|
||||
RouterCallable routerCallable = new RouterCallable() {
|
||||
@Override
|
||||
public Boolean call() {
|
||||
getRouter().route(httpRequestBuilder, httpResponseBuilder);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
httpRequestBuilder.release();
|
||||
httpResponseBuilder.release();
|
||||
}
|
||||
};
|
||||
Future<?> future = executor.submit(routerCallable);
|
||||
logger.log(Level.FINE, "dispatched " + future);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,10 +156,21 @@ public class BaseApplication implements Application {
|
|||
HttpResponseStatus httpResponseStatus) {
|
||||
HttpServerContext httpServerContext = createContext(null, httpRequestBuilder, httpResponseBuilder);
|
||||
httpServerContext.getAttributes().put("responsebuilder", httpResponseBuilder);
|
||||
StatusSubmittable submittable = new StatusSubmittable(httpRequestBuilder, httpResponseBuilder,
|
||||
httpResponseStatus, httpServerContext);
|
||||
Future<?> future = executor.submit(submittable);
|
||||
logger.log(Level.FINE, "dispatching status " + future);
|
||||
RouterCallable routerCallable = new RouterCallable() {
|
||||
@Override
|
||||
public Boolean call() {
|
||||
getRouter().routeStatus(httpResponseStatus, httpServerContext);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
httpRequestBuilder.release();
|
||||
httpResponseBuilder.release();
|
||||
}
|
||||
};
|
||||
Future<?> future = executor.submit(routerCallable);
|
||||
logger.log(Level.FINE, "dispatched status " + future);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -331,68 +359,4 @@ public class BaseApplication implements Application {
|
|||
logger.log(Level.INFO, "application closed");
|
||||
}
|
||||
|
||||
private class Submittable implements Runnable, Closeable {
|
||||
|
||||
private final HttpRequestBuilder httpRequestBuilder;
|
||||
|
||||
private final HttpResponseBuilder httpResponseBuilder;
|
||||
|
||||
private Submittable(HttpRequestBuilder httpRequestBuilder,
|
||||
HttpResponseBuilder httpResponseBuilder) {
|
||||
this.httpRequestBuilder = httpRequestBuilder;
|
||||
this.httpResponseBuilder = httpResponseBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
getRouter().route(httpRequestBuilder, httpResponseBuilder);
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, t.getMessage(), t);
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
httpRequestBuilder.close();
|
||||
httpResponseBuilder.close();
|
||||
}
|
||||
}
|
||||
|
||||
private class StatusSubmittable implements Runnable, Closeable {
|
||||
private final HttpRequestBuilder httpRequestBuilder;
|
||||
|
||||
private final HttpResponseBuilder httpResponseBuilder;
|
||||
|
||||
private final HttpResponseStatus httpResponseStatus;
|
||||
|
||||
private final HttpServerContext httpServerContext;
|
||||
|
||||
private StatusSubmittable(HttpRequestBuilder httpRequestBuilder,
|
||||
HttpResponseBuilder httpResponseBuilder,
|
||||
HttpResponseStatus httpResponseStatus,
|
||||
HttpServerContext httpServerContext) {
|
||||
this.httpRequestBuilder = httpRequestBuilder;
|
||||
this.httpResponseBuilder = httpResponseBuilder;
|
||||
this.httpResponseStatus = httpResponseStatus;
|
||||
this.httpServerContext = httpServerContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
getRouter().routeStatus(httpResponseStatus, httpServerContext);
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, t.getMessage(), t);
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
httpRequestBuilder.close();
|
||||
httpResponseBuilder.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,4 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.config.ConfigLoader;
|
||||
import org.xbib.config.ConfigLogger;
|
||||
import org.xbib.config.ConfigParams;
|
||||
import org.xbib.config.SystemConfigLogger;
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
import org.xbib.settings.Settings;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -20,6 +13,12 @@ import java.util.Set;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.config.ConfigLoader;
|
||||
import org.xbib.config.ConfigLogger;
|
||||
import org.xbib.config.ConfigParams;
|
||||
import org.xbib.config.SystemConfigLogger;
|
||||
import org.xbib.net.http.server.route.HttpRouter;
|
||||
import org.xbib.settings.Settings;
|
||||
|
||||
public class BaseApplicationBuilder implements ApplicationBuilder {
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
import org.xbib.net.http.server.session.Session;
|
||||
import org.xbib.settings.Settings;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.application;
|
||||
|
||||
public interface Resolver<R> {
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import org.xbib.net.buffer.Releasable;
|
||||
|
||||
public interface RouterCallable extends Callable<Boolean>, Releasable {
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.xbib.net.http.server.application;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
public class RouterTask<T> extends FutureTask<T> {
|
||||
|
||||
private final Callable<T> callable;
|
||||
|
||||
public RouterTask(Callable<T> callable) {
|
||||
super(callable);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
public Callable<T> getCallable() {
|
||||
return callable;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.Attributes;
|
||||
package org.xbib.net.http.server.auth;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import org.xbib.net.Attributes;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class BaseAttributes extends LinkedHashMap<String, Object> implements Attributes {
|
|
@ -1,11 +1,9 @@
|
|||
package org.xbib.net.http.server.auth;
|
||||
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.UserProfile;
|
||||
import org.xbib.net.http.server.BaseAttributes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.xbib.net.Attributes;
|
||||
import org.xbib.net.UserProfile;
|
||||
|
||||
public class BaseUserProfile implements UserProfile {
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.xbib.net.http.server.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.SecurityRealm;
|
||||
import org.xbib.net.UserProfile;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
|
@ -8,11 +12,6 @@ import org.xbib.net.http.server.HttpHandler;
|
|||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BasicAuthenticationHandler extends LoginAuthenticationHandler implements HttpHandler {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(BasicAuthenticationHandler.class.getName());
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.xbib.net.http.server.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.Authenticator;
|
||||
import org.xbib.net.GroupsProvider;
|
||||
import org.xbib.net.Parameter;
|
||||
|
@ -12,10 +15,6 @@ import org.xbib.net.UsersProvider;
|
|||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LoginAuthenticationHandler implements HttpHandler {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(LoginAuthenticationHandler.class.getName());
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.xbib.net.http.server.cookie;
|
||||
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.cookie.CookieHeaderNames;
|
||||
import org.xbib.net.http.cookie.DefaultCookie;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.cookie.CookieHeaderNames;
|
||||
import org.xbib.net.http.cookie.DefaultCookie;
|
||||
|
||||
/**
|
||||
* A <a href="http://tools.ietf.org/html/rfc6265">RFC6265</a> compliant cookie decoder to be used server side.
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.xbib.net.http.server.cookie;
|
||||
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.cookie.CookieHeaderNames;
|
||||
import org.xbib.net.http.cookie.CookieUtil;
|
||||
import org.xbib.net.util.DateTimeUtil;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.cookie.CookieHeaderNames;
|
||||
import org.xbib.net.http.cookie.CookieUtil;
|
||||
import org.xbib.net.util.DateTimeUtil;
|
||||
|
||||
/**
|
||||
* A <a href="http://tools.ietf.org/html/rfc6265">RFC6265</a> compliant cookie encoder to be used server side,
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package org.xbib.net.http.server.cookie;
|
||||
|
||||
import org.xbib.net.util.JsonUtil;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import org.xbib.net.util.JsonUtil;
|
||||
|
||||
public class CookieSignatureUtil {
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.xbib.net.http.server.cookie;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.cookie.CookieBox;
|
||||
|
@ -7,8 +8,6 @@ import org.xbib.net.http.server.HttpException;
|
|||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class IncomingCookieHandler implements HttpHandler {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(IncomingCookieHandler.class.getName());
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package org.xbib.net.http.server.cookie;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.http.cookie.Cookie;
|
||||
import org.xbib.net.http.cookie.CookieBox;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class OutgoingCookieHandler implements HttpHandler {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(OutgoingCookieHandler.class.getName());
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package org.xbib.net.http.server.decorate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.xbib.net.ParameterDefinition;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpSecurityDomain;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.HttpService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.xbib.net.http.server.domain.HttpSecurityDomain;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public class DecoratingHttpService implements HttpService {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.xbib.net.http.server.decorate;
|
||||
|
||||
import org.xbib.net.http.server.HttpServerConfig;
|
||||
import org.xbib.net.http.server.Service;
|
||||
import org.xbib.net.http.server.service.Service;
|
||||
|
||||
public abstract class DecoratingService extends AbstractUnwrappable<Service> implements Service {
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public class BaseHttpDomain implements HttpDomain {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -7,6 +7,7 @@ import java.util.LinkedHashSet;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public class BaseHttpDomainBuilder implements HttpDomainBuilder {
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.xbib.net.SecurityRealm;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
|
||||
public class BaseHttpSecurityDomain implements HttpSecurityDomain {
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.xbib.net.SecurityRealm;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
|
||||
public class BaseHttpSecurityDomainBuilder {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
/**
|
||||
* The {@code HttpDomain} interface represents a set of domain names attached to an HTTP address.
|
|
@ -1,8 +1,8 @@
|
|||
package org.xbib.net.http.server;
|
||||
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.service.HttpService;
|
||||
|
||||
public interface HttpDomainBuilder {
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package org.xbib.net.http.server;
|
||||
package org.xbib.net.http.server.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.xbib.net.SecurityDomain;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
|
||||
public interface HttpSecurityDomain extends SecurityDomain {
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
package org.xbib.net.http.server.handler;
|
||||
|
||||
import org.xbib.net.http.server.HttpErrorHandler;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpErrorHandler;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
public class InternalServerErrorHandler implements HttpErrorHandler {
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.xbib.net.http.server.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpErrorHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class NotFoundHandler implements HttpErrorHandler {
|
||||
|
||||
public NotFoundHandler() {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.xbib.net.http.server.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpErrorHandler;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class NotImplementedHandler implements HttpErrorHandler {
|
||||
|
||||
public NotImplementedHandler() {
|
||||
|
|
|
@ -3,8 +3,8 @@ package org.xbib.net.http.server.ldap;
|
|||
import java.util.Map;
|
||||
import org.xbib.net.Authenticator;
|
||||
import org.xbib.net.GroupsProvider;
|
||||
import org.xbib.net.UsersProvider;
|
||||
import org.xbib.net.SecurityRealm;
|
||||
import org.xbib.net.UsersProvider;
|
||||
|
||||
public class LdapRealm extends SecurityRealm {
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@ import javax.naming.NamingException;
|
|||
import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.SearchResult;
|
||||
import org.xbib.net.UsersProvider;
|
||||
import org.xbib.net.UserDetails;
|
||||
|
||||
import org.xbib.net.UsersProvider;
|
||||
import static java.lang.String.format;
|
||||
|
||||
public class LdapUsersProvider extends UsersProvider {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.xbib.net.http.server.persist.file;
|
||||
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
@ -12,6 +10,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
|
||||
public class FilePropertiesCodec implements Codec<Map<String, Object>> {
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package org.xbib.net.http.server.persist.memory;
|
||||
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.xbib.net.http.server.persist.Codec;
|
||||
|
||||
public class MemoryPropertiesCodec implements Codec<Map<String, Object>> {
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.xbib.net.http.server.render;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpResponse;
|
||||
import org.xbib.net.http.server.HttpResponseBuilder;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpResponseRenderer implements HttpHandler {
|
||||
|
||||
public HttpResponseRenderer() {
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DataBufferUtil;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpResponseBuilder;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.util.DateTimeUtil;
|
||||
import org.xbib.net.mime.MimeTypeService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -33,6 +18,20 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DataBufferUtil;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpHeaders;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpException;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpResponseBuilder;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.mime.MimeTypeService;
|
||||
import org.xbib.net.util.DateTimeUtil;
|
||||
|
||||
public abstract class AbstractResourceHandler implements HttpHandler {
|
||||
|
||||
|
@ -267,6 +266,7 @@ public abstract class AbstractResourceHandler implements HttpHandler {
|
|||
.append(StandardCharsets.ISO_8859_1.decode(dataBuffer.asByteBuffer()))
|
||||
.append('\n')
|
||||
.append("--MULTIPART_BOUNDARY--").append('\n');
|
||||
dataBuffer.release();
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
logger.log(Level.FINEST, e.getMessage(), e);
|
||||
}
|
||||
|
@ -345,9 +345,10 @@ public abstract class AbstractResourceHandler implements HttpHandler {
|
|||
} else {
|
||||
fileChannel = fileChannel.position(offset);
|
||||
try (ReadableByteChannel channel = fileChannel) {
|
||||
DataBuffer dataBuffer = DataBufferUtil.readBuffer(responseBuilder.getDataBufferFactory(), channel, size);
|
||||
responseBuilder.setResponseStatus(httpResponseStatus)
|
||||
.setContentType(contentType)
|
||||
.write(DataBufferUtil.readBuffer(responseBuilder.getDataBufferFactory(), channel, size));
|
||||
.write(dataBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,10 +364,11 @@ public abstract class AbstractResourceHandler implements HttpHandler {
|
|||
} else {
|
||||
long n = inputStream.skip(offset);
|
||||
try (ReadableByteChannel channel = Channels.newChannel(inputStream)) {
|
||||
DataBuffer dataBuffer = DataBufferUtil.readBuffer(responseBuilder.getDataBufferFactory(), channel, size);
|
||||
responseBuilder
|
||||
.setResponseStatus(httpResponseStatus)
|
||||
.setContentType(contentType)
|
||||
.write(DataBufferUtil.readBuffer(responseBuilder.getDataBufferFactory(), channel, size));
|
||||
.write(dataBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
|
||||
public class BaseResource implements Resource {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
public class ClassLoaderResourceHandler extends AbstractResourceHandler {
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Instant;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
|
||||
public class FileResourceHandler extends AbstractResourceHandler {
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.Application;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
import org.xbib.net.http.server.application.Application;
|
||||
|
||||
public class HtmlTemplateResource implements HttpServerResource {
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
public class HtmlTemplateResourceHandler extends AbstractResourceHandler {
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface HttpServerResource extends Resource {
|
||||
|
||||
void render(HttpServerContext httpServerContext) throws IOException;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.xbib.net.http.server.HttpHandler;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class MethodHandler implements HttpHandler {
|
||||
|
||||
private final Method m;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
public interface ResourceResolver {
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package org.xbib.net.http.server.resource;
|
||||
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import org.xbib.net.PathNormalizer;
|
||||
import org.xbib.net.Resource;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.net.http.HttpResponseStatus;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
import org.xbib.net.http.server.HttpServerContext;
|
||||
|
||||
public class WebRootResourceResolver implements ResourceResolver {
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package org.xbib.net.http.server.resource.negotiate;
|
||||
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.server.HttpRequest;
|
||||
|
||||
/**
|
||||
* Taken from org.apache.any23.servlet.conneg.ContentTypeNegotiator
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.xbib.net.http.server.route;
|
|||
|
||||
import org.xbib.datastructures.common.LinkedHashSetMultiMap;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.server.HttpDomain;
|
||||
import org.xbib.net.http.server.domain.HttpDomain;
|
||||
|
||||
public class BaseDomainsByAddress extends LinkedHashSetMultiMap<HttpAddress, HttpDomain> implements DomainsByAddress {
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package org.xbib.net.http.server.route;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
|
||||
public class BaseHttpRoute implements HttpRoute {
|
||||
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
package org.xbib.net.http.server.route;
|
||||
|
||||
import java.util.Set;
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.xbib.net.Parameter;
|
||||
import org.xbib.net.ParameterBuilder;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import static org.xbib.net.Parameter.Domain.PATH;
|
||||
|
||||
public class BaseHttpRouteResolver<T> implements HttpRouteResolver<T> {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue