Dedicated package for JDK http server
authorMathieu <mbaudier@argeo.org>
Sat, 3 Dec 2022 07:25:03 +0000 (08:25 +0100)
committerMathieu <mbaudier@argeo.org>
Sat, 3 Dec 2022 07:25:03 +0000 (08:25 +0100)
org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java
org.argeo.cms/src/org/argeo/cms/dav/DavHttpHandler.java
org.argeo.cms/src/org/argeo/cms/http/HttpServerUtils.java [deleted file]
org.argeo.cms/src/org/argeo/cms/http/server/HttpServerUtils.java [new file with mode: 0644]

index b670e5cf1bd1aca086a1289f0752dbade096032c..363bbaebe498362973675995c4c63e7c18e20ab6 100644 (file)
@@ -13,7 +13,7 @@ import javax.websocket.server.ServerContainer;
 import org.argeo.api.cms.CmsLog;
 import org.argeo.api.cms.CmsState;
 import org.argeo.cms.CmsDeployProperty;
-import org.argeo.cms.http.HttpServerUtils;
+import org.argeo.cms.http.server.HttpServerUtils;
 import org.eclipse.jetty.http.UriCompliance;
 import org.eclipse.jetty.server.HttpConfiguration;
 import org.eclipse.jetty.server.HttpConnectionFactory;
index 9fd03f25abb5cfd735cc712ea8938864df4d0b93..63f4f82c7574b5d936fdeb1336bfd7296f758cbf 100644 (file)
@@ -12,8 +12,8 @@ import javax.xml.namespace.NamespaceContext;
 import org.argeo.api.acr.ContentNotFoundException;
 import org.argeo.cms.http.HttpHeader;
 import org.argeo.cms.http.HttpMethod;
-import org.argeo.cms.http.HttpServerUtils;
 import org.argeo.cms.http.HttpStatus;
+import org.argeo.cms.http.server.HttpServerUtils;
 
 import com.sun.net.httpserver.HttpExchange;
 import com.sun.net.httpserver.HttpHandler;
diff --git a/org.argeo.cms/src/org/argeo/cms/http/HttpServerUtils.java b/org.argeo.cms/src/org/argeo/cms/http/HttpServerUtils.java
deleted file mode 100644 (file)
index 46f2922..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.argeo.cms.http;
-
-import java.net.URI;
-import java.util.Objects;
-
-import com.sun.net.httpserver.HttpContext;
-import com.sun.net.httpserver.HttpExchange;
-
-/** HTTP utilities on the server-side. */
-public class HttpServerUtils {
-       private final static String SLASH = "/";
-
-       private static String extractPathWithingContext(HttpContext httpContext, String fullPath, boolean startWithSlash) {
-               Objects.requireNonNull(fullPath);
-               String contextPath = httpContext.getPath();
-               if (!fullPath.startsWith(contextPath))
-                       throw new IllegalArgumentException(fullPath + " does not belong to context" + contextPath);
-               String path = fullPath.substring(contextPath.length());
-               // TODO optimise?
-               if (!startWithSlash && path.startsWith(SLASH)) {
-                       path = path.substring(1);
-               } else if (startWithSlash && !path.startsWith(SLASH)) {
-                       path = SLASH + path;
-               }
-               return path;
-       }
-
-       /** Path within the context, NOT starting with a slash. */
-       public static String relativize(HttpExchange exchange) {
-               URI uri = exchange.getRequestURI();
-               HttpContext httpContext = exchange.getHttpContext();
-               return extractPathWithingContext(httpContext, uri.getPath(), false);
-       }
-
-       /** Path within the context, starting with a slash. */
-       public static String subPath(HttpExchange exchange) {
-               URI uri = exchange.getRequestURI();
-               HttpContext httpContext = exchange.getHttpContext();
-               return extractPathWithingContext(httpContext, uri.getPath(), true);
-       }
-
-       /** singleton */
-       private HttpServerUtils() {
-
-       }
-}
diff --git a/org.argeo.cms/src/org/argeo/cms/http/server/HttpServerUtils.java b/org.argeo.cms/src/org/argeo/cms/http/server/HttpServerUtils.java
new file mode 100644 (file)
index 0000000..ab033f0
--- /dev/null
@@ -0,0 +1,46 @@
+package org.argeo.cms.http.server;
+
+import java.net.URI;
+import java.util.Objects;
+
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+
+/** HTTP utilities on the server-side. */
+public class HttpServerUtils {
+       private final static String SLASH = "/";
+
+       private static String extractPathWithingContext(HttpContext httpContext, String fullPath, boolean startWithSlash) {
+               Objects.requireNonNull(fullPath);
+               String contextPath = httpContext.getPath();
+               if (!fullPath.startsWith(contextPath))
+                       throw new IllegalArgumentException(fullPath + " does not belong to context" + contextPath);
+               String path = fullPath.substring(contextPath.length());
+               // TODO optimise?
+               if (!startWithSlash && path.startsWith(SLASH)) {
+                       path = path.substring(1);
+               } else if (startWithSlash && !path.startsWith(SLASH)) {
+                       path = SLASH + path;
+               }
+               return path;
+       }
+
+       /** Path within the context, NOT starting with a slash. */
+       public static String relativize(HttpExchange exchange) {
+               URI uri = exchange.getRequestURI();
+               HttpContext httpContext = exchange.getHttpContext();
+               return extractPathWithingContext(httpContext, uri.getPath(), false);
+       }
+
+       /** Path within the context, starting with a slash. */
+       public static String subPath(HttpExchange exchange) {
+               URI uri = exchange.getRequestURI();
+               HttpContext httpContext = exchange.getHttpContext();
+               return extractPathWithingContext(httpContext, uri.getPath(), true);
+       }
+
+       /** singleton */
+       private HttpServerUtils() {
+
+       }
+}