From fb062ebf04bf7798c3d1c58c7de4b5d8a1b59c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Fri, 24 Jul 2020 15:30:32 +0200 Subject: [PATCH] context URL, better interface and parameterized types for Domain and EndpointResolver --- gradle.properties | 2 +- .../xbib/netty/http/server/api/Domain.java | 24 +++++ .../http/server/api/EndpointResolver.java | 16 +++ .../netty/http/server/api/FilterConfig.java | 4 + .../netty/http/server/api/ServerConfig.java | 95 ++++++++++++++++ ...erConfig.java => DefaultServerConfig.java} | 74 +++++-------- .../{Domain.java => HttpServerDomain.java} | 102 ++++++++---------- .../org/xbib/netty/http/server/Server.java | 69 +++++++----- .../http/server/endpoint/HttpEndpoint.java | 1 - .../server/endpoint/HttpEndpointResolver.java | 29 +++-- .../endpoint/service/MethodService.java | 4 + .../endpoint/service/ResourceService.java | 4 + .../server/handler/ExtendedSNIHandler.java | 8 +- .../handler/http/Http1ChannelInitializer.java | 14 ++- .../http2/Http2ChannelInitializer.java | 14 +-- .../http/server/transport/BaseTransport.java | 4 +- .../http/server/transport/Http2Transport.java | 5 + .../http/server/test/BindExceptionTest.java | 4 +- .../http/server/test/ContextURLTest.java | 14 +-- .../test/MultiDomainSecureServerTest.java | 6 +- .../server/test/MultiDomainServerTest.java | 6 +- .../http/server/test/ThreadLeakTest.java | 4 +- .../TransportLayerSecurityServerTest.java | 6 +- .../test/endpoint/ClassloaderServiceTest.java | 6 +- .../server/test/endpoint/EndpointTest.java | 16 +-- .../server/test/endpoint/FileServiceTest.java | 12 +-- .../test/endpoint/SecureFileServiceTest.java | 8 +- .../http/server/test/http1/CleartextTest.java | 8 +- .../http/server/test/http1/EncryptedTest.java | 8 +- .../http/server/test/http1/FlushTest.java | 4 +- .../server/test/http1/MimeUploadTest.java | 4 +- .../http/server/test/http1/PostTest.java | 12 +-- .../netty/http/server/test/http1/PutTest.java | 6 +- .../http/server/test/http1/StreamTest.java | 4 +- .../http/server/test/http2/CleartextTest.java | 12 +-- .../http/server/test/http2/EncryptedTest.java | 8 +- .../http/server/test/http2/FlushTest.java | 4 +- .../server/test/http2/MixedProtocolTest.java | 8 +- .../http/server/test/http2/PostTest.java | 6 +- .../netty/http/server/test/http2/PutTest.java | 6 +- .../http/server/test/http2/StreamTest.java | 5 +- 41 files changed, 394 insertions(+), 252 deletions(-) create mode 100644 netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/Domain.java create mode 100644 netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/EndpointResolver.java create mode 100644 netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/FilterConfig.java create mode 100644 netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/ServerConfig.java rename netty-http-server/src/main/java/org/xbib/netty/http/server/{ServerConfig.java => DefaultServerConfig.java} (91%) rename netty-http-server/src/main/java/org/xbib/netty/http/server/{Domain.java => HttpServerDomain.java} (85%) diff --git a/gradle.properties b/gradle.properties index 95ae705..317d526 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = netty-http -version = 4.1.51.1 +version = 4.1.51.2 gradle.wrapper.version = 6.4.1 netty.version = 4.1.51.Final diff --git a/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/Domain.java b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/Domain.java new file mode 100644 index 0000000..f9c3c73 --- /dev/null +++ b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/Domain.java @@ -0,0 +1,24 @@ +package org.xbib.netty.http.server.api; + +import io.netty.handler.ssl.SslContext; +import org.xbib.netty.http.common.HttpAddress; +import java.io.IOException; +import java.security.cert.X509Certificate; +import java.util.Collection; + +public interface Domain> { + + HttpAddress getHttpAddress(); + + String getName(); + + Collection getHttpEndpointResolvers(); + + SslContext getSslContext(); + + Collection getCertificateChain(); + + String findContextPathOf(ServerRequest serverRequest) throws IOException; + + void handle(ServerRequest serverRequest, ServerResponse serverResponse) throws IOException; +} diff --git a/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/EndpointResolver.java b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/EndpointResolver.java new file mode 100644 index 0000000..418bf86 --- /dev/null +++ b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/EndpointResolver.java @@ -0,0 +1,16 @@ +package org.xbib.netty.http.server.api; + +import java.io.IOException; +import java.util.List; + +public interface EndpointResolver> { + + List matchingEndpointsFor(ServerRequest serverRequest); + + void resolve(List matchingEndpoints, + ServerRequest serverRequest) throws IOException; + + void handle(List matchingEndpoints, + ServerRequest serverRequest, + ServerResponse serverResponse) throws IOException; +} diff --git a/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/FilterConfig.java b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/FilterConfig.java new file mode 100644 index 0000000..998b458 --- /dev/null +++ b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/FilterConfig.java @@ -0,0 +1,4 @@ +package org.xbib.netty.http.server.api; + +public interface FilterConfig { +} diff --git a/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/ServerConfig.java b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/ServerConfig.java new file mode 100644 index 0000000..65eb31d --- /dev/null +++ b/netty-http-server-api/src/main/java/org/xbib/netty/http/server/api/ServerConfig.java @@ -0,0 +1,95 @@ +package org.xbib.netty.http.server.api; + +import io.netty.channel.WriteBufferWaterMark; +import io.netty.handler.codec.http2.Http2Settings; +import io.netty.handler.logging.LogLevel; +import io.netty.handler.ssl.CipherSuiteFilter; +import io.netty.handler.ssl.SslProvider; +import org.xbib.netty.http.common.HttpAddress; +import java.security.KeyStore; +import java.security.Provider; +import java.util.Collection; +import javax.net.ssl.TrustManagerFactory; + +public interface ServerConfig { + + boolean isDebug(); + + LogLevel getTrafficDebugLogLevel(); + + String getTransportProviderName(); + + int getParentThreadCount(); + + int getChildThreadCount(); + + int getBlockingThreadCount(); + + int getBlockingQueueCount(); + + boolean isReuseAddr(); + + boolean isTcpNodelay(); + + int getTcpSendBufferSize(); + + int getTcpReceiveBufferSize(); + + int getBackLogSize(); + + int getConnectTimeoutMillis(); + + int getReadTimeoutMillis(); + + int getIdleTimeoutMillis(); + + HttpAddress getAddress(); + + int getMaxInitialLineLength(); + + int getMaxHeadersSize(); + + int getMaxChunkSize(); + + int getMaxContentLength(); + + int getPipeliningCapacity(); + + int getMaxCompositeBufferComponents(); + + WriteBufferWaterMark getWriteBufferWaterMark(); + + boolean isCompressionEnabled(); + + int getCompressionThreshold(); + + boolean isDecompressionEnabled(); + + boolean isInstallHttp2Upgrade(); + + Http2Settings getHttp2Settings(); + + TrustManagerFactory getTrustManagerFactory(); + + KeyStore getTrustManagerKeyStore(); + + SslProvider getSslProvider(); + + Provider getSslContextProvider(); + + String[] getProtocols(); + + Iterable getCiphers(); + + CipherSuiteFilter getCipherSuiteFilter(); + + boolean isAutoDomain(); + + boolean isAcceptInvalidCertificates(); + + Collection>> getDomains(); + + Domain> getDomain(String name); + + Domain> getDefaultDomain(); +} diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/ServerConfig.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/DefaultServerConfig.java similarity index 91% rename from netty-http-server/src/main/java/org/xbib/netty/http/server/ServerConfig.java rename to netty-http-server/src/main/java/org/xbib/netty/http/server/DefaultServerConfig.java index 0a69a7c..7098558 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/ServerConfig.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/DefaultServerConfig.java @@ -7,15 +7,18 @@ import io.netty.handler.ssl.CipherSuiteFilter; import io.netty.handler.ssl.SslProvider; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.security.SecurityUtil; - +import org.xbib.netty.http.server.api.Domain; +import org.xbib.netty.http.server.api.EndpointResolver; +import org.xbib.netty.http.server.api.ServerConfig; import java.security.KeyStore; import java.security.Provider; import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.Deque; +import java.util.LinkedList; +import java.util.Optional; import javax.net.ssl.TrustManagerFactory; -public class ServerConfig { +public class DefaultServerConfig implements ServerConfig { interface Defaults { @@ -246,7 +249,7 @@ public class ServerConfig { private boolean installHttp2Upgrade = Defaults.INSTALL_HTTP_UPGRADE2; - private final Map domains; + private final Deque>> domains; private SslProvider sslProvider = Defaults.SSL_PROVIDER; @@ -266,21 +269,17 @@ public class ServerConfig { private boolean acceptInvalidCertificates = false; - public ServerConfig() { - this.domains = new LinkedHashMap<>(); + public DefaultServerConfig() { + this.domains = new LinkedList<>(); } - public ServerConfig enableDebug() { - this.debug = true; + public ServerConfig setDebug(boolean debug) { + this.debug = debug; return this; } - public ServerConfig disableDebug() { - this.debug = false; - return this; - } - - public boolean isTrafficDebug() { + @Override + public boolean isDebug() { return debug; } @@ -618,42 +617,27 @@ public class ServerConfig { return acceptInvalidCertificates; } - public ServerConfig checkAndAddDomain(Domain domain) { - if (domains.containsKey(domain.getName())) { - return this; - } - domains.put(domain.getName(), domain); - for (String alias : domain.getAliases()) { - domains.put(alias, domain); - } + public ServerConfig addDomain(Domain> domain) { + domains.add(domain); return this; } - public Collection getDomains() { - return domains.values(); + @Override + public Collection>> getDomains() { + return domains; } - public ServerConfig removeDomain(String name) { - domains.remove(name); - return this; + @Override + public Domain> getDomain(String name) { + Optional>> domainOptional = + domains.stream().filter(d -> d.getName().equals(name)).findFirst(); + return domainOptional.orElse(domains.getFirst()); } - public ServerConfig removeDomain(Domain domain) { - domains.remove(domain.getName()); - for (String alias : domain.getAliases()) { - domains.remove(alias, domain); - } - return this; - } - - public Domain getDomain(String name) { - Domain domain = domains.get(name); - return domain != null ? domain : getDefaultDomain(); - } - - public Domain getDefaultDomain() { - Domain defaultDomain = domains.get("*"); - return defaultDomain != null ? defaultDomain : - !domains.isEmpty() ? domains.values().iterator().next() : null; + @Override + public Domain> getDefaultDomain() { + Optional>> domainOptional = + domains.stream().filter(d -> d.getName().equals("*")).findFirst(); + return domainOptional.orElse(domains.getFirst()); } } diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/Domain.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/HttpServerDomain.java similarity index 85% rename from netty-http-server/src/main/java/org/xbib/netty/http/server/Domain.java rename to netty-http-server/src/main/java/org/xbib/netty/http/server/HttpServerDomain.java index e348691..6c47d71 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/Domain.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/HttpServerDomain.java @@ -8,6 +8,8 @@ import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslProvider; import org.xbib.netty.http.common.HttpAddress; +import org.xbib.netty.http.server.api.Domain; +import org.xbib.netty.http.server.api.EndpointResolver; import org.xbib.netty.http.server.api.security.ServerCertificateProvider; import org.xbib.netty.http.common.security.SecurityUtil; import org.xbib.netty.http.server.api.ServerRequest; @@ -33,33 +35,29 @@ import java.security.spec.InvalidKeySpecException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.ServiceLoader; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; /** - * The {@code Domain} class represents a virtual server with a name, with or without SSL. + * The {@code HttpServerDomain} class represents a virtual server with a name. */ -public class Domain { +public class HttpServerDomain implements Domain { - private static final Logger logger = Logger.getLogger(Domain.class.getName()); + private static final Logger logger = Logger.getLogger(HttpServerDomain.class.getName()); private static final String EMPTY = ""; private final String name; - private final Set aliases; - private final HttpAddress httpAddress; private final SslContext sslContext; - private final List httpEndpointResolvers; + private final Collection httpEndpointResolvers; private final Collection certificates; @@ -67,19 +65,16 @@ public class Domain { * Constructs a {@code NamedServer} with the given name. * * @param name the name, or null if it is the default server - * @param aliases alias names for the named server * @param httpAddress HTTP address, used for determining if named server is secure or not * @param httpEndpointResolvers the endpoint resolvers * @param sslContext SSL context or null */ - private Domain(String name, - Set aliases, - HttpAddress httpAddress, - List httpEndpointResolvers, - SslContext sslContext, - Collection certificates) { + private HttpServerDomain(String name, + HttpAddress httpAddress, + Collection httpEndpointResolvers, + SslContext sslContext, + Collection certificates) { this.name = name; - this.aliases = aliases; this.httpAddress = httpAddress; this.httpEndpointResolvers = httpEndpointResolvers; this.sslContext = sslContext; @@ -94,7 +89,7 @@ public class Domain { return new Builder(httpAddress).setServerName(serverName); } - public static Builder builder(Domain domain) { + public static Builder builder(Domain> domain) { return new Builder(domain); } @@ -103,6 +98,7 @@ public class Domain { * * @return the HTTP address */ + @Override public HttpAddress getHttpAddress() { return httpAddress; } @@ -112,23 +108,21 @@ public class Domain { * * @return the name, or null if it is the default server */ + @Override public String getName() { return name; } - /** - * Returns the aliases. - * - * @return the (unmodifiable) set of aliases (which may be empty) - */ - public Set getAliases() { - return aliases; + @Override + public Collection getHttpEndpointResolvers() { + return httpEndpointResolvers; } /** * Returns SSL context. * @return the SSL context */ + @Override public SslContext getSslContext() { return sslContext; } @@ -137,6 +131,7 @@ public class Domain { * Get certificate chain. * @return the certificate chain or null if not secure */ + @Override public Collection getCertificateChain() { return certificates; } @@ -149,13 +144,14 @@ public class Domain { * @return the context path * @throws IOException if handling fails */ - public String findContextOf(ServerRequest serverRequest) throws IOException { + @Override + public String findContextPathOf(ServerRequest serverRequest) throws IOException { if (serverRequest == null) { return EMPTY; } Map.Entry> resolved = resolve(serverRequest); if (resolved != null) { - resolved.getKey().handle(resolved.getValue(), serverRequest, null, false); + resolved.getKey().resolve(resolved.getValue(), serverRequest); return serverRequest.getContextPath(); } return null; @@ -167,22 +163,28 @@ public class Domain { * @param serverResponse the server response * @throws IOException if handling server request fails */ + @Override public void handle(ServerRequest serverRequest, ServerResponse serverResponse) throws IOException { Map.Entry> resolved = resolve(serverRequest); if (resolved != null) { - resolved.getKey().handle(resolved.getValue(), serverRequest, serverResponse, true); + resolved.getKey().handle(resolved.getValue(), serverRequest, serverResponse); } else { - ServerResponse.write(serverResponse, HttpResponseStatus.NOT_IMPLEMENTED, - "text/plain", "No endpoint match for request " + serverRequest); + ServerResponse.write(serverResponse, HttpResponseStatus.NOT_FOUND, + "text/plain", "No endpoint found to match request"); } } + @Override + public String toString() { + return name + " (" + httpAddress + ")"; + } + /** * Just resolve a server request to a matching endpoint resolver with endpoints matched. * @param serverRequest the server request * @return the endpoint resolver together with the matching endpoints */ - public Map.Entry> resolve(ServerRequest serverRequest) { + private Map.Entry> resolve(ServerRequest serverRequest) { for (HttpEndpointResolver httpEndpointResolver : httpEndpointResolvers) { List matchingEndpoints = httpEndpointResolver.matchingEndpointsFor(serverRequest); if (!matchingEndpoints.isEmpty()) { @@ -192,20 +194,13 @@ public class Domain { return null; } - @Override - public String toString() { - return name + " (" + httpAddress + ") aliases=" + aliases; - } - public static class Builder { private final HttpAddress httpAddress; private String serverName; - private final Set aliases; - - private final List httpEndpointResolvers; + private final Collection httpEndpointResolvers; private SslContext sslContext; @@ -228,7 +223,6 @@ public class Domain { private Builder(HttpAddress httpAddress) { Objects.requireNonNull(httpAddress); this.httpAddress = httpAddress; - this.aliases = new LinkedHashSet<>(); this.httpEndpointResolvers = new ArrayList<>(); this.trustManagerFactory = SecurityUtil.Defaults.DEFAULT_TRUST_MANAGER_FACTORY; this.sslProvider = SecurityUtil.Defaults.DEFAULT_SSL_PROVIDER; @@ -236,12 +230,12 @@ public class Domain { this.cipherSuiteFilter = SecurityUtil.Defaults.DEFAULT_CIPHER_SUITE_FILTER; } - private Builder(Domain domain) { - this.httpAddress = domain.httpAddress; - this.aliases = new LinkedHashSet<>(); - this.httpEndpointResolvers = new ArrayList<>(domain.httpEndpointResolvers); - this.sslContext = domain.sslContext; - this.keyCertChain = domain.certificates; + @SuppressWarnings("unchecked") + private Builder(Domain> domain) { + this.httpAddress = domain.getHttpAddress(); + this.httpEndpointResolvers = new ArrayList<>((List) domain.getHttpEndpointResolvers()); + this.sslContext = domain.getSslContext(); + this.keyCertChain = domain.getCertificateChain(); } public Builder setServerName(String serverName) { @@ -338,18 +332,6 @@ public class Domain { return this; } - /** - * Adds an alias for this virtual server. - * - * @param alias the alias - * @return this builder - */ - public Builder addAlias(String alias) { - Objects.requireNonNull(alias); - aliases.add(alias); - return this; - } - public Builder addEndpointResolver(HttpEndpointResolver httpEndpointResolver) { Objects.requireNonNull(httpEndpointResolver); this.httpEndpointResolvers.add(httpEndpointResolver); @@ -399,7 +381,7 @@ public class Domain { return this; } - public Domain build() { + public HttpServerDomain build() { if (httpEndpointResolvers.isEmpty()) { throw new IllegalArgumentException("domain must have at least one endpoint resolver"); } @@ -420,14 +402,14 @@ public class Domain { } this.sslContext = sslContextBuilder.build(); } - return new Domain(serverName, aliases, + return new HttpServerDomain(serverName, httpAddress, httpEndpointResolvers, sslContext, keyCertChain); } catch (Exception e) { throw new RuntimeException(e); } } else { - return new Domain(serverName, aliases, + return new HttpServerDomain(serverName, httpAddress, httpEndpointResolvers, null, null); } diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java index 4ffdffb..5d3ab02 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java @@ -19,10 +19,13 @@ import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.NetworkUtils; import org.xbib.netty.http.common.HttpChannelInitializer; import org.xbib.netty.http.common.TransportProvider; +import org.xbib.netty.http.server.api.Domain; +import org.xbib.netty.http.server.api.EndpointResolver; import org.xbib.netty.http.server.api.ServerProtocolProvider; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.api.ServerTransport; +import org.xbib.netty.http.server.endpoint.HttpEndpointResolver; import org.xbib.netty.http.server.security.CertificateUtils; import org.xbib.netty.http.server.transport.HttpServerRequest; import java.io.IOException; @@ -71,7 +74,7 @@ public final class Server implements AutoCloseable { private static final AtomicLong responseCounter = new AtomicLong(0); - private final ServerConfig serverConfig; + private final DefaultServerConfig serverConfig; private final EventLoopGroup parentEventLoopGroup; @@ -98,7 +101,7 @@ public final class Server implements AutoCloseable { * @param socketChannelClass socket channel class */ @SuppressWarnings("unchecked") - private Server(ServerConfig serverConfig, + private Server(DefaultServerConfig serverConfig, ByteBufAllocator byteBufAllocator, EventLoopGroup parentEventLoopGroup, EventLoopGroup childEventLoopGroup, @@ -133,7 +136,7 @@ public final class Server implements AutoCloseable { .childOption(ChannelOption.SO_RCVBUF, serverConfig.getTcpReceiveBufferSize()) .childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, serverConfig.getConnectTimeoutMillis()) .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, serverConfig.getWriteBufferWaterMark()); - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { bootstrap.handler(new LoggingHandler("bootstrap-server", serverConfig.getTrafficDebugLogLevel())); } if (serverConfig.getDefaultDomain() == null) { @@ -141,13 +144,13 @@ public final class Server implements AutoCloseable { } // translate domains into Netty mapping Mapping domainNameMapping = null; - Domain defaultDomain = serverConfig.getDefaultDomain(); + Domain> defaultDomain = serverConfig.getDefaultDomain(); if (serverConfig.getAddress().isSecure() && defaultDomain != null && defaultDomain.getSslContext() != null) { DomainWildcardMappingBuilder mappingBuilder = new DomainWildcardMappingBuilder<>(defaultDomain.getSslContext()); - for (Domain domain : serverConfig.getDomains()) { + for (Domain> domain : serverConfig.getDomains()) { if (!domain.getName().equals(defaultDomain.getName())) { mappingBuilder.add(domain.getName(), domain.getSslContext()); } @@ -168,11 +171,11 @@ public final class Server implements AutoCloseable { } } - public static Builder builder(Domain defaultDomain) { - return new Builder(defaultDomain); + public static Builder builder(HttpServerDomain httpServerDomain) { + return new Builder(httpServerDomain); } - public ServerConfig getServerConfig() { + public DefaultServerConfig getServerConfig() { return serverConfig; } @@ -199,7 +202,7 @@ public final class Server implements AutoCloseable { * @param serverRequest the server request * @return the domain */ - public Domain getDomain(ServerRequest serverRequest) { + public Domain> getDomain(ServerRequest serverRequest) { return getDomain(getBaseURL(serverRequest)); } @@ -208,7 +211,7 @@ public final class Server implements AutoCloseable { * @param url the URL * @return the domain */ - public Domain getDomain(URL url) { + public Domain> getDomain(URL url) { return getDomain(hostAndPort(url)); } @@ -219,7 +222,7 @@ public final class Server implements AutoCloseable { * default domain * @return the virtual host with the given name or the default domain */ - public Domain getDomain(String name) { + public Domain> getDomain(String name) { return serverConfig.getDomain(name); } @@ -277,13 +280,16 @@ public final class Server implements AutoCloseable { */ public URL getContextURL(ServerRequest serverRequest) throws IOException { URL baseURL = getBaseURL(serverRequest); - Domain domain = getDomain(baseURL); - String context = domain.findContextOf(serverRequest); + Domain> domain = getDomain(baseURL); + String context = domain.findContextPathOf(serverRequest); + if (!context.endsWith("/")) { + context = context + "/"; + } return baseURL.resolve(context); } public void handle(HttpServerRequest serverRequest, ServerResponse serverResponse) throws IOException { - Domain domain = getDomain(serverRequest); + Domain> domain = getDomain(serverRequest); logger.log(Level.FINEST, () -> "found domain " + domain + " for " + serverRequest); if (executor != null) { executor.submit(() -> { @@ -393,7 +399,7 @@ public final class Server implements AutoCloseable { throw new IllegalStateException("no channel initializer found for major version " + majorVersion); } - private static EventLoopGroup createParentEventLoopGroup(ServerConfig serverConfig, + private static EventLoopGroup createParentEventLoopGroup(DefaultServerConfig serverConfig, EventLoopGroup parentEventLoopGroup ) { EventLoopGroup eventLoopGroup = parentEventLoopGroup; if (eventLoopGroup == null) { @@ -411,8 +417,8 @@ public final class Server implements AutoCloseable { return eventLoopGroup; } - private static EventLoopGroup createChildEventLoopGroup(ServerConfig serverConfig, - EventLoopGroup childEventLoopGroup ) { + private static EventLoopGroup createChildEventLoopGroup(DefaultServerConfig serverConfig, + EventLoopGroup childEventLoopGroup ) { EventLoopGroup eventLoopGroup = childEventLoopGroup; if (eventLoopGroup == null) { ServiceLoader transportProviders = ServiceLoader.load(TransportProvider.class); @@ -429,7 +435,7 @@ public final class Server implements AutoCloseable { return eventLoopGroup; } - private static Class createSocketChannelClass(ServerConfig serverConfig, + private static Class createSocketChannelClass(DefaultServerConfig serverConfig, Class socketChannelClass) { Class channelClass = socketChannelClass; if (channelClass == null) { @@ -536,16 +542,21 @@ public final class Server implements AutoCloseable { private Class socketChannelClass; - private final ServerConfig serverConfig; + private final DefaultServerConfig serverConfig; - private Builder(Domain defaultDomain) { - this.serverConfig = new ServerConfig(); - this.serverConfig.setAddress(defaultDomain.getHttpAddress()); - addDomain(defaultDomain); + private Builder(HttpServerDomain httpServerDomain) { + this.serverConfig = new DefaultServerConfig(); + this.serverConfig.setAddress(httpServerDomain.getHttpAddress()); + addDomain(httpServerDomain); } public Builder enableDebug() { - this.serverConfig.enableDebug(); + this.serverConfig.setDebug(true); + return this; + } + + public Builder setDebug(boolean debug) { + this.serverConfig.setDebug(debug); return this; } @@ -684,8 +695,8 @@ public final class Server implements AutoCloseable { return this; } - public Builder addDomain(Domain domain) { - this.serverConfig.checkAndAddDomain(domain); + public Builder addDomain(Domain domain) { + this.serverConfig.addDomain(domain); return this; } @@ -700,7 +711,7 @@ public final class Server implements AutoCloseable { } if (serverConfig.isAutoDomain()) { // unpack subject alternative names into separate domains - for (Domain domain : serverConfig.getDomains()) { + for (Domain> domain : serverConfig.getDomains()) { try { CertificateUtils.processSubjectAlternativeNames(domain.getCertificateChain(), new CertificateUtils.SubjectAlternativeNamesProcessor() { @@ -710,7 +721,7 @@ public final class Server implements AutoCloseable { @Override public void setSubjectAlternativeName(String subjectAlternativeName) { - Domain alternativeDomain = Domain.builder(domain) + HttpServerDomain alternativeDomain = HttpServerDomain.builder(domain) .setServerName(subjectAlternativeName) .build(); addDomain(alternativeDomain); @@ -721,7 +732,7 @@ public final class Server implements AutoCloseable { } } } - for (Domain domain : serverConfig.getDomains()) { + for (Domain> domain : serverConfig.getDomains()) { if (domain.getCertificateChain() != null) { for (X509Certificate certificate : domain.getCertificateChain()) { try { diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java index 1c4fef4..fdfc1fa 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java @@ -9,7 +9,6 @@ import org.xbib.netty.http.server.api.Endpoint; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.api.Filter; - import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpointResolver.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpointResolver.java index 5f40749..bcb562b 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpointResolver.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpointResolver.java @@ -2,6 +2,7 @@ package org.xbib.netty.http.server.endpoint; import org.xbib.netty.http.common.util.LimitedConcurrentHashMap; import org.xbib.netty.http.server.api.EndpointDispatcher; +import org.xbib.netty.http.server.api.EndpointResolver; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.api.annotation.Endpoint; @@ -16,7 +17,7 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -public class HttpEndpointResolver { +public class HttpEndpointResolver implements EndpointResolver { private static final int DEFAULT_LIMIT = 1024; @@ -40,6 +41,7 @@ public class HttpEndpointResolver { * @param serverRequest the server request * @return a */ + @Override public List matchingEndpointsFor(ServerRequest serverRequest) { HttpEndpointDescriptor httpEndpointDescriptor = new HttpEndpointDescriptor(serverRequest); endpointDescriptors.putIfAbsent(httpEndpointDescriptor, endpoints.stream() @@ -49,21 +51,28 @@ public class HttpEndpointResolver { return endpointDescriptors.get(httpEndpointDescriptor); } + @Override + public void resolve(List matchingEndpoints, + ServerRequest serverRequest) throws IOException { + Objects.requireNonNull(matchingEndpoints); + for (HttpEndpoint endpoint : matchingEndpoints) { + endpoint.resolveUriTemplate(serverRequest); + endpoint.before(serverRequest, null); + break; + } + } + + @Override public void handle(List matchingEndpoints, ServerRequest serverRequest, - ServerResponse serverResponse, - boolean dispatch) throws IOException { + ServerResponse serverResponse) throws IOException { Objects.requireNonNull(matchingEndpoints); for (HttpEndpoint endpoint : matchingEndpoints) { endpoint.resolveUriTemplate(serverRequest); endpoint.before(serverRequest, serverResponse); - if (dispatch) { - endpointDispatcher.dispatch(endpoint, serverRequest, serverResponse); - endpoint.after(serverRequest, serverResponse); - if (serverResponse != null && serverResponse.getStatus() != null) { - break; - } - } else { + endpointDispatcher.dispatch(endpoint, serverRequest, serverResponse); + endpoint.after(serverRequest, serverResponse); + if (serverResponse != null && serverResponse.getStatus() != null) { break; } } diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/MethodService.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/MethodService.java index e6d1843..39ccb12 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/MethodService.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/MethodService.java @@ -1,6 +1,7 @@ package org.xbib.netty.http.server.endpoint.service; import org.xbib.netty.http.server.api.Filter; +import org.xbib.netty.http.server.api.FilterConfig; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; @@ -30,6 +31,9 @@ public class MethodService implements Filter { } } + public void initialize(FilterConfig filterConfig) { + } + @Override public void handle(ServerRequest serverRequest, ServerResponse serverResponse) throws IOException { try { diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/ResourceService.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/ResourceService.java index 1a33fe1..8bfbf8a 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/ResourceService.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/service/ResourceService.java @@ -8,6 +8,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.stream.ChunkedNioStream; import org.xbib.netty.http.common.util.DateTimeUtil; import org.xbib.netty.http.server.api.Filter; +import org.xbib.netty.http.server.api.FilterConfig; import org.xbib.netty.http.server.api.Resource; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; @@ -39,6 +40,9 @@ public abstract class ResourceService implements Filter { private static final Logger logger = Logger.getLogger(ResourceService.class.getName()); + public void initialize(FilterConfig filterConfig) { + } + @Override public void handle(ServerRequest serverRequest, ServerResponse serverResponse) throws IOException { handleCachedResource(serverRequest, serverResponse, createResource(serverRequest, serverResponse)); diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/ExtendedSNIHandler.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/ExtendedSNIHandler.java index 96972d8..25c529e 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/ExtendedSNIHandler.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/ExtendedSNIHandler.java @@ -6,7 +6,7 @@ import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslHandler; import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.ServerConfig; +import org.xbib.netty.http.server.DefaultServerConfig; import java.net.InetSocketAddress; import java.util.Arrays; import java.util.logging.Level; @@ -18,12 +18,12 @@ public class ExtendedSNIHandler extends SniHandler { private static final Logger logger = Logger.getLogger(ExtendedSNIHandler.class.getName()); - private final ServerConfig serverConfig; + private final DefaultServerConfig serverConfig; private final HttpAddress httpAddress; public ExtendedSNIHandler(Mapping mapping, - ServerConfig serverConfig, HttpAddress httpAddress) { + DefaultServerConfig serverConfig, HttpAddress httpAddress) { super(mapping); this.serverConfig = serverConfig; this.httpAddress = httpAddress; @@ -35,7 +35,7 @@ public class ExtendedSNIHandler extends SniHandler { } private static SslHandler newSslHandler(SslContext sslContext, - ServerConfig serverConfig, + DefaultServerConfig serverConfig, ByteBufAllocator allocator, HttpAddress httpAddress) { InetSocketAddress peer = httpAddress.getInetSocketAddress(); diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java index 9dcfcc1..9bc4045 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java @@ -18,10 +18,11 @@ import io.netty.handler.codec.http.HttpVersion; import io.netty.handler.logging.LogLevel; import io.netty.handler.ssl.SslContext; import io.netty.handler.stream.ChunkedWriteHandler; +import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.ServerConfig; +import org.xbib.netty.http.server.DefaultServerConfig; import org.xbib.netty.http.common.HttpChannelInitializer; import org.xbib.netty.http.server.handler.ExtendedSNIHandler; import org.xbib.netty.http.server.handler.IdleTimeoutHandler; @@ -39,7 +40,7 @@ public class Http1ChannelInitializer extends ChannelInitializer private final Server server; - private final ServerConfig serverConfig; + private final DefaultServerConfig serverConfig; private final HttpAddress httpAddress; @@ -58,7 +59,7 @@ public class Http1ChannelInitializer extends ChannelInitializer public void initChannel(Channel channel) { ServerTransport transport = server.newTransport(httpAddress.getVersion()); channel.attr(ServerTransport.TRANSPORT_ATTRIBUTE_KEY).set(transport); - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { channel.pipeline().addLast(new TrafficLoggingHandler(LogLevel.DEBUG)); } if (httpAddress.isSecure()) { @@ -66,7 +67,7 @@ public class Http1ChannelInitializer extends ChannelInitializer } else { configureCleartext(channel); } - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { logger.log(Level.FINE, "HTTP 1.1 server channel initialized: " + " address=" + httpAddress + " pipeline=" + channel.pipeline().names()); } @@ -80,7 +81,10 @@ public class Http1ChannelInitializer extends ChannelInitializer private void configureCleartext(Channel channel) { ChannelPipeline pipeline = channel.pipeline(); - pipeline.addLast("http-server-chunked-write", new ChunkedWriteHandler()); + pipeline.addLast("http-server-read-timeout", + new ReadTimeoutHandler(serverConfig.getReadTimeoutMillis())); + pipeline.addLast("http-server-chunked-write", + new ChunkedWriteHandler()); pipeline.addLast("http-server-codec", new HttpServerCodec(serverConfig.getMaxInitialLineLength(), serverConfig.getMaxHeadersSize(), serverConfig.getMaxChunkSize())); diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java index df4b55d..4db873b 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java @@ -29,11 +29,12 @@ import io.netty.handler.codec.http2.Http2StreamFrameToHttpObjectCodec; import io.netty.handler.logging.LogLevel; import io.netty.handler.ssl.SslContext; import io.netty.handler.stream.ChunkedWriteHandler; +import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.util.AsciiString; import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.ServerConfig; +import org.xbib.netty.http.server.DefaultServerConfig; import org.xbib.netty.http.common.HttpChannelInitializer; import org.xbib.netty.http.server.handler.ExtendedSNIHandler; import org.xbib.netty.http.server.handler.IdleTimeoutHandler; @@ -51,7 +52,7 @@ public class Http2ChannelInitializer extends ChannelInitializer private final Server server; - private final ServerConfig serverConfig; + private final DefaultServerConfig serverConfig; private final HttpAddress httpAddress; @@ -70,7 +71,7 @@ public class Http2ChannelInitializer extends ChannelInitializer public void initChannel(Channel channel) { ServerTransport transport = server.newTransport(httpAddress.getVersion()); channel.attr(ServerTransport.TRANSPORT_ATTRIBUTE_KEY).set(transport); - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { channel.pipeline().addLast(new TrafficLoggingHandler(LogLevel.DEBUG)); } if (httpAddress.isSecure()) { @@ -78,7 +79,7 @@ public class Http2ChannelInitializer extends ChannelInitializer } else { configureCleartext(channel); } - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { logger.log(Level.FINE, "HTTP/2 server channel initialized: " + " address=" + httpAddress + " pipeline=" + channel.pipeline().names()); } @@ -97,6 +98,8 @@ public class Http2ChannelInitializer extends ChannelInitializer ServerTransport transport = server.newTransport(httpAddress.getVersion()); channel.attr(ServerTransport.TRANSPORT_ATTRIBUTE_KEY).set(transport); ChannelPipeline pipeline = channel.pipeline(); + pipeline.addLast("server-read-timeout", + new ReadTimeoutHandler(serverConfig.getReadTimeoutMillis())); pipeline.addLast("server-frame-converter", new Http2StreamFrameToHttpObjectCodec(true)); if (serverConfig.isCompressionEnabled()) { @@ -114,7 +117,7 @@ public class Http2ChannelInitializer extends ChannelInitializer }; Http2MultiplexCodecBuilder multiplexCodecBuilder = Http2MultiplexCodecBuilder.forServer(channelHandler) .initialSettings(Http2Settings.defaultSettings()); - if (serverConfig.isTrafficDebug()) { + if (serverConfig.isDebug()) { multiplexCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, "server")); } Http2MultiplexCodec multiplexCodec = multiplexCodecBuilder.build(); @@ -159,7 +162,6 @@ public class Http2ChannelInitializer extends ChannelInitializer @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { - ServerTransport transport = ctx.channel().attr(ServerTransport.TRANSPORT_ATTRIBUTE_KEY).get(); ctx.fireUserEventTriggered(evt); } diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/BaseTransport.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/BaseTransport.java index 106a0e2..06e4fac 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/BaseTransport.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/BaseTransport.java @@ -6,7 +6,7 @@ import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.ServerConfig; +import org.xbib.netty.http.server.DefaultServerConfig; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.api.ServerTransport; @@ -39,7 +39,7 @@ abstract class BaseTransport implements ServerTransport { * @param serverResponse the response * @return whether further processing should be performed */ - static boolean acceptRequest(ServerConfig serverConfig, + static boolean acceptRequest(DefaultServerConfig serverConfig, ServerRequest serverRequest, ServerResponse serverResponse) { HttpVersion version = serverConfig.getAddress().getVersion(); diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/Http2Transport.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/Http2Transport.java index f0c1e50..369cd38 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/Http2Transport.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/transport/Http2Transport.java @@ -5,6 +5,7 @@ import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http2.Http2Settings; import io.netty.handler.codec.http2.HttpConversionUtil; +import io.netty.handler.ssl.SslHandler; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; @@ -29,6 +30,10 @@ public class Http2Transport extends BaseTransport { serverRequest.setSequenceId(sequenceId); serverRequest.setRequestId(server.getRequestCounter().incrementAndGet()); serverRequest.setStreamId(fullHttpRequest.headers().getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text())); + SslHandler sslHandler = ctx.channel().pipeline().get(SslHandler.class); + if (sslHandler != null) { + serverRequest.setSession(sslHandler.engine().getSession()); + } ServerResponse serverResponse = new Http2ServerResponse(server, serverRequest, ctx); if (acceptRequest(server.getServerConfig(), serverRequest, serverResponse)) { serverRequest.handleParameters(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/BindExceptionTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/BindExceptionTest.java index 263823d..77fc1b7 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/BindExceptionTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/BindExceptionTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import java.io.IOException; import java.net.BindException; @@ -18,7 +18,7 @@ class BindExceptionTest { @Test void testDoubleServer() throws IOException { - Domain domain = Domain.builder(HttpAddress.http1("localhost", 8008)) + HttpServerDomain domain = HttpServerDomain.builder(HttpAddress.http1("localhost", 8008)) .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello World")) .build(); Server server1 = Server.builder(domain).build(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ContextURLTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ContextURLTest.java index 35ec48f..cb71cd9 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ContextURLTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ContextURLTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.xbib.net.URL; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerRequest; import org.xbib.netty.http.server.endpoint.HttpEndpoint; @@ -35,10 +35,10 @@ public class ContextURLTest { .setDispatcher((endpoint, serverRequest, serverResponse) -> {}) .build(); - Domain one = Domain.builder(httpAddress, "domain.one:8008") + HttpServerDomain one = HttpServerDomain.builder(httpAddress, "domain.one:8008") .addEndpointResolver(endpointResolver1) .build(); - Domain two = Domain.builder(one) + HttpServerDomain two = HttpServerDomain.builder(one) .setServerName("domain.two:8008") .addEndpointResolver(endpointResolver2) .addEndpointResolver(endpointResolver3) @@ -49,27 +49,27 @@ public class ContextURLTest { .build(); URL url0 = server.getContextURL(); - assertEquals("http://localhost:8008", url0.toString()); + assertEquals("http://localhost:8008/", url0.toString()); DefaultFullHttpRequest fullHttpRequest1 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/one"); fullHttpRequest1.headers().add("host", "domain.one:8008"); ServerRequest serverRequest1 = new HttpServerRequest(fullHttpRequest1); URL url1 = server.getContextURL(serverRequest1); assertEquals("domain.one", url1.getHost()); - assertEquals("/one", url1.getPath()); + assertEquals("/one/", url1.getPath()); DefaultFullHttpRequest fullHttpRequest2 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/two"); fullHttpRequest2.headers().add("host", "domain.two:8008"); ServerRequest serverRequest2 = new HttpServerRequest(fullHttpRequest2); URL url2 = server.getContextURL(serverRequest2); assertEquals("domain.two", url2.getHost()); - assertEquals("/two", url2.getPath()); + assertEquals("/two/", url2.getPath()); DefaultFullHttpRequest fullHttpRequest3 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/three"); fullHttpRequest3.headers().add("host", "domain.two:8008"); ServerRequest serverRequest3 = new HttpServerRequest(fullHttpRequest3); URL url3 = server.getContextURL(serverRequest3); assertEquals("domain.two", url3.getHost()); - assertEquals("/three", url3.getPath()); + assertEquals("/three/", url3.getPath()); } } diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainSecureServerTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainSecureServerTest.java index 85e8338..85dbf98 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainSecureServerTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainSecureServerTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import java.io.InputStream; @@ -32,12 +32,12 @@ class MultiDomainSecureServerTest { return; } HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8443); - Domain fl = Domain.builder(httpAddress, "fl.hbz-nrw.de") + HttpServerDomain fl = HttpServerDomain.builder(httpAddress, "fl.hbz-nrw.de") .setKeyCertChain(certInputStream) .setKey(keyInputStream, null) .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello fl.hbz-nrw.de")) .build(); - Domain zfl2 = Domain.builder(fl) + HttpServerDomain zfl2 = HttpServerDomain.builder(fl) .setServerName("zfl2.hbz-nrw.de") .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello zfl2.hbz-nrw.de")) .build(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainServerTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainServerTest.java index c9441fa..23d3725 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainServerTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/MultiDomainServerTest.java @@ -9,7 +9,7 @@ import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import java.nio.charset.StandardCharsets; import java.util.logging.Level; import java.util.logging.Logger; @@ -23,10 +23,10 @@ class MultiDomainServerTest { @Test void testServer() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain fl = Domain.builder(httpAddress, "fl.hbz-nrw.de") + HttpServerDomain fl = HttpServerDomain.builder(httpAddress, "fl.hbz-nrw.de") .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello fl.hbz-nrw.de")) .build(); - Domain zfl2 = Domain.builder(fl) + HttpServerDomain zfl2 = HttpServerDomain.builder(fl) .setServerName("zfl2.hbz-nrw.de") .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello zfl2.hbz-nrw.de")) .build(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ThreadLeakTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ThreadLeakTest.java index da4fd0a..317a237 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ThreadLeakTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/ThreadLeakTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import java.io.IOException; import java.util.Set; @@ -23,7 +23,7 @@ class ThreadLeakTest { @Test void testForLeaks() throws IOException { - Domain domain = Domain.builder(HttpAddress.http1("localhost", 8008)) + HttpServerDomain domain = HttpServerDomain.builder(HttpAddress.http1("localhost", 8008)) .singleEndpoint("/", (request, response) -> ServerResponse.write(response, "Hello World")) .build(); Server server = Server.builder(domain) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/TransportLayerSecurityServerTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/TransportLayerSecurityServerTest.java index 4f45a1a..763e35a 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/TransportLayerSecurityServerTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/TransportLayerSecurityServerTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.client.api.ClientTransport; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import java.nio.charset.StandardCharsets; import java.util.concurrent.atomic.AtomicInteger; @@ -26,7 +26,7 @@ class TransportLayerSecurityServerTest { @Test void testTLS12() throws Exception { HttpAddress httpAddress = HttpAddress.secureHttp1("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) @@ -64,7 +64,7 @@ class TransportLayerSecurityServerTest { @Test void testTLS13() throws Exception { HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/ClassloaderServiceTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/ClassloaderServiceTest.java index be9e7d5..4bbd9a0 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/ClassloaderServiceTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/ClassloaderServiceTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.endpoint.service.ClassLoaderService; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -27,7 +27,7 @@ class ClassloaderServiceTest { @Test void testClassloaderFileResource() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/classloader", "/**", new ClassLoaderService(ClassloaderServiceTest.class, "/cl")) .build(); @@ -65,7 +65,7 @@ class ClassloaderServiceTest { @Test void testClassloaderDirectoryResource() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/classloader", "/**", new ClassLoaderService(ClassloaderServiceTest.class, "/cl")) .build(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java index 843a5a1..d7118c6 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.endpoint.HttpEndpoint; import org.xbib.netty.http.server.endpoint.HttpEndpointResolver; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.endpoint.service.FileService; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -46,7 +46,7 @@ class EndpointTest { fileService.handle(req, resp); }) .build(); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(httpEndpointResolver) .build(); Server server = Server.builder(domain) @@ -87,7 +87,7 @@ class EndpointTest { fileService.handle(req, resp); }) .build(); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(httpEndpointResolver) .build(); Server server = Server.builder(domain) @@ -130,7 +130,7 @@ class EndpointTest { fileService.handle(req, resp); }) .build(); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(httpEndpointResolver) .build(); Server server = Server.builder(domain) @@ -196,7 +196,7 @@ class EndpointTest { fileService.handle(req, resp); }) .build(); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(httpEndpointResolver) .build(); Server server = Server.builder(domain) @@ -293,7 +293,7 @@ class EndpointTest { fileService3.handle(req, resp); }) .build(); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(httpEndpointResolver1) .addEndpointResolver(httpEndpointResolver2) .addEndpointResolver(httpEndpointResolver3) @@ -376,7 +376,7 @@ class EndpointTest { .setPath("/" + i + "/**") .build()); } - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .addEndpointResolver(endpointResolverBuilder .setDispatcher((endpoint,req, resp) -> ServerResponse.write(resp, HttpResponseStatus.OK)) .build()) @@ -415,7 +415,7 @@ class EndpointTest { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); HttpEndpointResolver.Builder endpointResolverBuilder = HttpEndpointResolver.builder() .setPrefix("/static"); - Domain.Builder domainBuilder = Domain.builder(httpAddress); + HttpServerDomain.Builder domainBuilder = HttpServerDomain.builder(httpAddress); for (int i = 0; i < max; i++) { domainBuilder.addEndpointResolver(endpointResolverBuilder.addEndpoint(HttpEndpoint.builder() .setPath("/" + i + "/**").build()) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/FileServiceTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/FileServiceTest.java index 57ffb20..07d3832 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/FileServiceTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/FileServiceTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.endpoint.service.FileService; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -32,7 +32,7 @@ class FileServiceTest { void testFileServiceHttp1() throws Exception { Path vartmp = Paths.get("/var/tmp/"); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/static", "/**", new FileService(vartmp)) .build(); Server server = Server.builder(domain) @@ -65,7 +65,7 @@ class FileServiceTest { void testFileServiceHttp2() throws Exception { Path vartmp = Paths.get("/var/tmp/"); HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/static", "/**", new FileService(vartmp)) .build(); Server server = Server.builder(domain) @@ -101,7 +101,7 @@ class FileServiceTest { Files.createDirectories(vartmpforward); Files.write(vartmpforward.resolve("test.txt"), "Hello Jörg".getBytes(StandardCharsets.UTF_8)); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/static", "/**", new FileService(vartmp, "test.txt")) .build(); Server server = Server.builder(domain) @@ -138,7 +138,7 @@ class FileServiceTest { Files.createDirectories(vartmpforward); Files.write(vartmpforward.resolve("test.txt"), "Hello Jörg".getBytes(StandardCharsets.UTF_8)); HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/static", "/**", new FileService(vartmp, "test.txt")) .build(); Server server = Server.builder(domain) @@ -178,7 +178,7 @@ class FileServiceTest { Files.createDirectories(vartmpforward); Files.write(vartmpforward.resolve("test.txt"), "Hello Jörg".getBytes(StandardCharsets.UTF_8)); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/static", "/**", new FileService(vartmp, "test.txt")) .build(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/SecureFileServiceTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/SecureFileServiceTest.java index 775f721..b53fdf7 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/SecureFileServiceTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/SecureFileServiceTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.endpoint.service.FileService; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -32,7 +32,7 @@ class SecureFileServiceTest { void testSecureFileServerHttp1() throws Exception { Path vartmp = Paths.get("/var/tmp/"); HttpAddress httpAddress = HttpAddress.secureHttp1("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress, "*") + Server server = Server.builder(HttpServerDomain.builder(httpAddress, "*") .setJdkSslProvider() .setSelfCert() .singleEndpoint("/static", "/**", new FileService(vartmp)) @@ -68,7 +68,7 @@ class SecureFileServiceTest { void testSecureFileServerHttp2() throws Exception { Path vartmp = Paths.get("/var/tmp/"); HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress, "*") + Server server = Server.builder(HttpServerDomain.builder(httpAddress, "*") .setOpenSSLSslProvider() //.setJdkSslProvider() .setSelfCert() @@ -112,7 +112,7 @@ class SecureFileServiceTest { void testSecureFileServerMixHttp1Http2() throws Exception { Path vartmp = Paths.get("/var/tmp/"); HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress, "*") + Server server = Server.builder(HttpServerDomain.builder(httpAddress, "*") .setOpenSSLSslProvider() .setSelfCert() .singleEndpoint("/static", "/**", new FileService(vartmp)) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/CleartextTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/CleartextTest.java index 3998732..2ab876c 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/CleartextTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/CleartextTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.client.api.ClientTransport; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -33,7 +33,7 @@ class CleartextTest { @Test void testSimpleClearTextHttp1() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/**", (request, response) -> ServerResponse.write(response, HttpResponseStatus.OK, "text/plain", request.getContent().toString(StandardCharsets.UTF_8))) @@ -67,7 +67,7 @@ class CleartextTest { void testPooledClearTextHttp1() throws Exception { int loop = 1; HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/**", (request, response) -> ServerResponse.write(response, HttpResponseStatus.OK, "text/plain", request.getContent().toString(StandardCharsets.UTF_8))) @@ -112,7 +112,7 @@ class CleartextTest { int threads = 4; int loop = 1024; HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/**", (request, response) -> ServerResponse.write(response, HttpResponseStatus.OK, "text/plain", request.getContent().toString(StandardCharsets.UTF_8))) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/EncryptedTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/EncryptedTest.java index ba74bfe..2542af4 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/EncryptedTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/EncryptedTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.client.api.ClientTransport; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.io.IOException; @@ -32,7 +32,7 @@ class EncryptedTest { @Test void testSimpleSecureHttp1() throws Exception { HttpAddress httpAddress = HttpAddress.secureHttp1("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) @@ -63,7 +63,7 @@ class EncryptedTest { void testPooledSecureHttp1() throws Exception { int loop = 4096; HttpAddress httpAddress = HttpAddress.secureHttp1("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) @@ -107,7 +107,7 @@ class EncryptedTest { int threads = 4; int loop = 4 * 1024; HttpAddress httpAddress = HttpAddress.secureHttp1("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/FlushTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/FlushTest.java index 237a1dd..fb8c4db 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/FlushTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/FlushTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpParameters; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.util.concurrent.atomic.AtomicBoolean; @@ -33,7 +33,7 @@ class FlushTest { @Test void testFlushHttp1() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/flush", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending 302 Found"); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/MimeUploadTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/MimeUploadTest.java index 780b02d..ce6dbeb 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/MimeUploadTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/MimeUploadTest.java @@ -15,7 +15,7 @@ import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpParameters; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -33,7 +33,7 @@ class MimeUploadTest { void testMimetHttp1() throws Exception { final AtomicBoolean success1 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/upload", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request, headers = " + req.getHeaders() + diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PostTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PostTest.java index 5a510c3..00b3182 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PostTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PostTest.java @@ -9,7 +9,7 @@ import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpParameters; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -32,7 +32,7 @@ class PostTest { final AtomicBoolean success2 = new AtomicBoolean(false); final AtomicBoolean success3 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending OK"); @@ -82,7 +82,7 @@ class PostTest { final AtomicBoolean success2 = new AtomicBoolean(false); final AtomicBoolean success3 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending OK"); @@ -133,7 +133,7 @@ class PostTest { final AtomicBoolean success3 = new AtomicBoolean(false); final AtomicBoolean success4 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending OK"); @@ -190,7 +190,7 @@ class PostTest { final AtomicBoolean success3 = new AtomicBoolean(false); final AtomicBoolean success4 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending OK"); @@ -247,7 +247,7 @@ class PostTest { final AtomicBoolean success2 = new AtomicBoolean(false); final AtomicBoolean success3 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending OK"); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PutTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PutTest.java index ec46238..be025b3 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PutTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/PutTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -32,7 +32,7 @@ class PutTest { final AtomicBoolean success1 = new AtomicBoolean(false); final AtomicBoolean success2 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/put", "/**", (req, resp) -> { logger.log(Level.INFO, "got request " + req.getContent().toString(StandardCharsets.UTF_8)); @@ -80,7 +80,7 @@ class PutTest { outputStream.write(1); } HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/put", "/**", (req, resp) -> { logger.log(Level.INFO, "got request, length = " + req.getContent().readableBytes()); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/StreamTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/StreamTest.java index 1cea92f..0b75e1e 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/StreamTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http1/StreamTest.java @@ -9,7 +9,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -24,7 +24,7 @@ class StreamTest { @Test void testServerBodyInputStreamHttp1() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> { ByteBufInputStream inputStream = request.getInputStream(); String content = inputStream.readLine(); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/CleartextTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/CleartextTest.java index 3147743..3f9b528 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/CleartextTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/CleartextTest.java @@ -11,7 +11,7 @@ import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.nio.charset.StandardCharsets; @@ -32,7 +32,7 @@ class CleartextTest { @Test void testSimpleCleartextHttp2() throws Exception { HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> ServerResponse.write(response, HttpResponseStatus.OK, "text.plain", request.getContent().toString(StandardCharsets.UTF_8))) @@ -77,7 +77,7 @@ class CleartextTest { void testPooledClearTextHttp2() throws Exception { int loop = 1024; HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) .withContentType("text/plain") @@ -129,7 +129,7 @@ class CleartextTest { int threads = 4; int loop = 1024; HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/**", (request, response) -> ServerResponse.write(response, HttpResponseStatus.OK, "text/plain", request.getContent().toString(StandardCharsets.UTF_8))) @@ -198,7 +198,7 @@ class CleartextTest { int loop = 1000; HttpAddress httpAddress1 = HttpAddress.http2("localhost", 8008); AtomicInteger counter1 = new AtomicInteger(); - Domain domain1 = Domain.builder(httpAddress1) + HttpServerDomain domain1 = HttpServerDomain.builder(httpAddress1) .singleEndpoint("/", (request, response) -> { ServerResponse.write(response, HttpResponseStatus.OK, "text.plain", request.getContent().toString(StandardCharsets.UTF_8)); @@ -210,7 +210,7 @@ class CleartextTest { server1.accept(); HttpAddress httpAddress2 = HttpAddress.http2("localhost", 8009); AtomicInteger counter2 = new AtomicInteger(); - Domain domain2 = Domain.builder(httpAddress2) + HttpServerDomain domain2 = HttpServerDomain.builder(httpAddress2) .singleEndpoint("/", (request, response) -> { ServerResponse.write(response, HttpResponseStatus.OK, "text/plain", request.getContent().toString(StandardCharsets.UTF_8)); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/EncryptedTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/EncryptedTest.java index 17cd51c..a05384c 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/EncryptedTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/EncryptedTest.java @@ -10,7 +10,7 @@ import org.xbib.netty.http.client.api.ClientTransport; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; import org.xbib.netty.http.server.Server; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.nio.charset.StandardCharsets; @@ -31,7 +31,7 @@ class EncryptedTest { @Test void testSimpleSecureHttp2() throws Exception { HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) @@ -72,7 +72,7 @@ class EncryptedTest { void testPooledSecureHttp2() throws Exception { int loop = 1024; HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) @@ -126,7 +126,7 @@ class EncryptedTest { int threads = 4; int loop = 1024; HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Server server = Server.builder(Domain.builder(httpAddress) + Server server = Server.builder(HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> response.withStatus(HttpResponseStatus.OK) diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/FlushTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/FlushTest.java index df5b465..b71932e 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/FlushTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/FlushTest.java @@ -9,7 +9,7 @@ import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpParameters; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.util.concurrent.atomic.AtomicBoolean; @@ -30,7 +30,7 @@ class FlushTest { @Test void testFlushHttp2() throws Exception { HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/flush", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + ", sending 302 Found"); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/MixedProtocolTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/MixedProtocolTest.java index 4606421..ac16520 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/MixedProtocolTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/MixedProtocolTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.client.api.ClientTransport; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -21,7 +21,7 @@ class MixedProtocolTest { @Test void testHttp1ClientHttp2Server() throws Exception { HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> { ServerResponse.write(response, HttpResponseStatus.OK); }) @@ -55,7 +55,7 @@ class MixedProtocolTest { @Test void testHttp2ClientHttp1Server() throws Exception { HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> { ServerResponse.write(response, HttpResponseStatus.OK); }) @@ -92,7 +92,7 @@ class MixedProtocolTest { @Test void testHttp1ClientHttp2ServerWithNegotiation() throws Exception { HttpAddress httpAddress = HttpAddress.secureHttp2("localhost", 8143); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .setSelfCert() .singleEndpoint("/", (request, response) -> { ServerResponse.write(response, HttpResponseStatus.OK); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PostTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PostTest.java index 0ca30b5..f67a038 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PostTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PostTest.java @@ -12,7 +12,7 @@ import org.xbib.netty.http.common.HttpParameters; import org.xbib.netty.http.common.HttpResponse; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.nio.charset.StandardCharsets; @@ -33,7 +33,7 @@ class PostTest { final AtomicBoolean success2 = new AtomicBoolean(false); final AtomicBoolean success3 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + " , sending, OK"); @@ -83,7 +83,7 @@ class PostTest { final AtomicBoolean success2 = new AtomicBoolean(false); final AtomicBoolean success3 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/post", "/**", (req, resp) -> { HttpParameters parameters = req.getParameters(); logger.log(Level.INFO, "got request " + parameters.toString() + " , sending, OK"); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PutTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PutTest.java index 52e8988..9aeee3f 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PutTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/PutTest.java @@ -8,7 +8,7 @@ import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.client.api.ResponseListener; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.HttpResponse; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.api.ServerResponse; import org.xbib.netty.http.server.test.NettyHttpTestExtension; @@ -31,7 +31,7 @@ class PutTest { final AtomicBoolean success1 = new AtomicBoolean(false); final AtomicBoolean success2 = new AtomicBoolean(false); HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/put", "/**", (req, resp) -> { logger.log(Level.INFO, "got request " + req.getContent().toString(StandardCharsets.UTF_8)); @@ -80,7 +80,7 @@ class PutTest { outputStream.write(1); } HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/put", "/**", (req, resp) -> { logger.log(Level.INFO, "got request, length = " + req.getContent().readableBytes()); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/StreamTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/StreamTest.java index 5e571c1..856a3c0 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/StreamTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/http2/StreamTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.xbib.netty.http.client.Client; import org.xbib.netty.http.client.api.Request; import org.xbib.netty.http.common.HttpAddress; -import org.xbib.netty.http.server.Domain; +import org.xbib.netty.http.server.HttpServerDomain; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.test.NettyHttpTestExtension; import java.nio.charset.StandardCharsets; @@ -14,7 +14,6 @@ import java.util.concurrent.atomic.AtomicInteger; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; import io.netty.handler.codec.http.HttpResponseStatus; -import io.netty.handler.codec.http.HttpVersion; @ExtendWith(NettyHttpTestExtension.class) class StreamTest { @@ -22,7 +21,7 @@ class StreamTest { @Test void testServerBodyInputStreamHttp2() throws Exception { HttpAddress httpAddress = HttpAddress.http2("localhost", 8008); - Domain domain = Domain.builder(httpAddress) + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) .singleEndpoint("/", (request, response) -> { ByteBufInputStream inputStream = request.getInputStream(); String content = inputStream.readLine();