diff --git a/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc b/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc index 1634c26eda6..4a205a3f685 100644 --- a/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc @@ -55,6 +55,7 @@ When executed `start.jar` performs the following actions: * Loads and parses all INIs found in `${jetty.base}/start.d/*.ini` as command line arguments. * Loads and parses `${jetty.base}/start.ini` as command line arguments. +** Please see link:#start-vs-startd[Start.ini vs. Start.d] for more information on the difference between these. * Parses actual command line arguments used to execute `start.jar` itself. * Resolves any XML configuration files, modules, and libraries using base vs. home resolution steps: 1. Checks whether file exists as relative reference to `${jetty.base}.` @@ -217,3 +218,18 @@ The time (in seconds) to wait for confirmation that the running Jetty server has If not specified, the stopper waits indefinitely for the server to stop. + If the time specified elapses, without a confirmation of server stop, then the `--stop` command exits with a non-zero return code. + +===== Advanced Commands + +--lib=:: +Add arbitrary classpath entries to the the server classpath. + +--include-jetty-dir=:: +Include an extra Jetty directory to use as a source for configuration details. +This directory behaves similarly to `${jetty.base}` but sits at a layer between `${jetty.base}` and `${jetty.home}`. +This allows for some complex hierarchies of configuration details. + +--download=|:: +If the file does not exist at the given location, download it from the given http URI. +Note: location is always relative to `${jetty.base}`. +You might need to escape the slash "\|" to use this on some environments. diff --git a/jetty-documentation/src/main/asciidoc/administration/startup/startup-base-vs-home.adoc b/jetty-documentation/src/main/asciidoc/administration/startup/startup-base-vs-home.adoc index 5dd8ef12e5e..496c50c99c7 100644 --- a/jetty-documentation/src/main/asciidoc/administration/startup/startup-base-vs-home.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/startup/startup-base-vs-home.adoc @@ -18,7 +18,7 @@ === Managing Jetty Base and Jetty Home Instead of managing multiple Jetty implementations out of several different distribution locations, it is possible to maintain a separation between the binary installation of the standalone Jetty (known as `${jetty.home}`), and the customizations for your specific environment(s) (known as `${jetty.base}`). -There should always only be one Jetty Home, but there can be multiple Jetty Base directories that references. +There should always only be *one* Jetty Home (per version of Jetty), but there can be multiple Jetty Base directories that reference it. Jetty Base:: * Also known as the `${jetty.base}` property. @@ -36,26 +36,22 @@ ____ [[base-vs-home-resolution]] Potential configuration is resolved from these 2 directory locations. +When Jetty starts up in processes configuration from them as follows: -Check Jetty Base:: - If the referenced configuration exists, relative to the defined Jetty base, use it. -Check Jetty Home:: - If the referenced configuration exists, relative to the defined Jetty home, use it. +Check Jetty Base First:: + If the referenced configuration exists, relative to the defined Jetty base, it is used. +Check Jetty Home Second:: + If the referenced configuration exists, relative to the defined Jetty home, it is used. Use java.io.File(String pathname) Logic:: - Lastly, use the reference as a `java.io.File(String pathname)` reference, following the default resolution rules outlined by that constructor. + Lastly, use the reference as a `java.io.File(String pathname)` reference, following the default resolution rules outlined by that constructor. In brief, the reference will be used as-is, be it relative (to current working directory, aka $\{user.dir}) or absolute path, or even network reference (such as on Windows and use of UNC paths). -+ -In brief, the reference will be used as-is, be it relative (to current working directory, aka $\{user.dir}) or absolute path, or even network reference (such as on Windows and use of UNC paths). - -For more details on how startup with start.jar works, see link:#execute-start-jar[Using start.jar: Executing] +For more details on how startup with start.jar works, see link:#executing-startjar[Using start.jar: Executing] [[demo-base]] ==== Demo-Base in the Jetty Distribution The Jetty Distribution comes with an example `${jetty.base}` which enables the various demonstration webapps and server configurations. -How to use the demo-base directory as a Jetty Base directory. - [source, screen, subs="{sub-order}"] .... [jetty-distribution-{VERSION}]$ ls -la @@ -89,31 +85,39 @@ drwxrwxr-x 2 user group 4096 Oct 8 06:54 webapps/ ... .... -As you can see above, you are executing the demo-base configuration using the Jetty base concepts. - -If you want to see what the Jetty base looks like without executing Jetty, you can simply list the configuration +If you want to see what the Jetty base looks like without executing Jetty, you can simply list the configuration by using the `--list-config` command. [source, screen, subs="{sub-order}"] .... -[my-base]$ java -jar $JETTY_HOME/start.jar --list-config +[demo-base]$ java -jar $JETTY_HOME/start.jar --list-config Java Environment: ----------------- java.home=/usr/lib/jvm/jdk-7u21-x64/jre - java.vm.vendor=Oracle Corporation - java.vm.version=23.21-b01 - java.vm.name=Java HotSpot(TM) 64-Bit Server VM - java.vm.info=mixed mode - java.runtime.name=Java(TM) SE Runtime Environment - java.runtime.version=1.7.0_21-b11 - java.io.tmpdir=/tmp + java.vm.vendor = Oracle Corporation + java.vm.version = 25.92-b14 + java.vm.name = Java HotSpot(TM) 64-Bit Server VM + java.vm.info = mixed mode + java.runtime.name = Java(TM) SE Runtime Environment + java.runtime.version = 1.8.0_92-b14 + java.io.tmpdir = /var/folders/h6/yb_lbnnn11g0y1jjlvqg631h0000gn/T/ + user.dir = /home/user/jetty-distribution-{VERSION} + user.language = en + user.country = US Jetty Environment: ----------------- jetty.home=/home/user/jetty-distribution-{VERSION} + jetty.tag.version = master jetty.base=/home/user/jetty-distribution-{VERSION}/demo-base jetty.version={VERSION} + Config Search Order: + -------------------- + + ${jetty.base} -> /home/user/jetty-distribution-9.4.1.v20170120/demo-base + ${jetty.home} -> /home/user/Desktop/jetty-distribution-9.4.1.v20170120 + JVM Arguments: -------------- (no jvm args specified) @@ -194,20 +198,22 @@ Note: order presented here is how they would appear on the classpath. Jetty Active XMLs: ------------------ ${jetty.home}/etc/jetty.xml - ${jetty.home}/etc/jetty-http.xml - ${jetty.home}/etc/jetty-jaas.xml - ${jetty.home}/etc/jetty-rewrite.xml - ${jetty.home}/etc/jetty-ssl.xml - ${jetty.home}/etc/jetty-https.xml + ${jetty.home}/etc/jetty-webapp.xml ${jetty.home}/etc/jetty-plus.xml ${jetty.home}/etc/jetty-annotations.xml ${jetty.home}/etc/jetty-deploy.xml + ${jetty.home}/etc/jetty-http.xml + ${jetty.home}/etc/jetty-ssl.xml + ${jetty.home}/etc/jetty-ssl-context.xml + ${jetty.home}/etc/jetty-https.xml + ${jetty.home}/etc/jetty-jaas.xml + ${jetty.home}/etc/jetty-rewrite.xml ${jetty.base}/etc/demo-rewrite-rules.xml ${jetty.base}/etc/test-realm.xml .... -This demonstrates the powerful `--list-config` command line option and how you can use it to see what the configuration will look like when starting Jetty. -From the Java environment, to the system properties, to the classpath, and finally the Active Jetty IoC XML used to build up the Jetty server configuration. +The `--list-config` command line option displays what the configuration will look like when starting Jetty. +This includes information on the Java environment to the system properties, the classpath and the Active Jetty IoC XML used to build up the Jetty server configuration. Of note, is that the output will make it known where the configuration elements came from, be it in either in `${jetty.home}` or `${jetty.base}`. diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java index 45032d9e112..40c4c99b2d8 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java @@ -29,6 +29,8 @@ import java.nio.charset.StandardCharsets; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** @@ -59,6 +61,8 @@ import org.eclipse.jetty.util.StringUtil; */ public class HttpTester { + private final static Logger LOG = Log.getLogger(HttpTester.class); + private HttpTester() { } @@ -212,7 +216,17 @@ public class HttpTester } public static Response parseResponse(Input in) throws IOException - { + { + return parseResponse(in, false); + } + + public static Response parsePartialResponse(Input in) throws IOException + { + return parseResponse(in, true); + } + + private static Response parseResponse(Input in, boolean allowIncomplete) throws IOException + { Response r; HttpParser parser=in.takeHttpParser(); if (parser==null) @@ -241,8 +255,11 @@ public class HttpTester } } - if (r.isComplete()) + if (allowIncomplete || r.isComplete()) return r; + + LOG.info("Incomplete Response: (parser={}) {}", parser, r); + in.setHttpParser(parser); return null; } diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTesterTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTesterTest.java index c0e642ae887..4ecfaf277ba 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTesterTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTesterTest.java @@ -20,7 +20,7 @@ package org.eclipse.jetty.http; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -30,14 +30,11 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import org.junit.Ignore; import org.junit.Test; public class HttpTesterTest { - @Test - @Ignore public void testExampleUsage() throws Exception { try(Socket socket = new Socket("www.google.com",80)) @@ -59,10 +56,8 @@ public class HttpTesterTest System.err.printf("%s: %s%n",field.getName(),field.getValue()); System.err.printf("%n%s%n",response.getContent()); } - } - @Test public void testGetRequestBuffer10() { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/AbstractHttpTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/AbstractHttpTest.java index 88f4c73f2f0..66d20d92bc4 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/AbstractHttpTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/AbstractHttpTest.java @@ -92,7 +92,8 @@ public abstract class AbstractHttpTest writer.write("\r\n"); writer.flush(); - HttpTester.Response response = HttpTester.parseResponse(socket.getInputStream()); + HttpTester.Input input = HttpTester.from(socket.getInputStream()); + HttpTester.Response response = HttpTester.parsePartialResponse(input); if ("HTTP/1.1".equals(httpVersion) && response.get("content-length") == null && response.get("transfer-encoding") == null diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToCommitTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToCommitTest.java index bf7062f97c7..c4e0b90f911 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToCommitTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToCommitTest.java @@ -18,13 +18,13 @@ package org.eclipse.jetty.server; -import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; import java.io.EOFException; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; @@ -429,10 +429,12 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest try { HttpTester.Response response = executeRequest(); - String failed_body = ""+(char)-1+(char)-1+(char)-1; assertThat("response code", response.getStatus(), is(200)); - assertThat(response.getContent(), endsWith(failed_body)); assertHeader(response, "content-length", "6"); + byte content[] = response.getContentBytes(); + assertThat("content bytes", content.length, is(6)); + String contentStr = new String(content, StandardCharsets.UTF_8); + assertThat("content bytes as string", contentStr, is("foo")); } catch(EOFException e) { @@ -449,10 +451,12 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest try { HttpTester.Response response = executeRequest(); - String failed_body = ""+(char)-1+(char)-1+(char)-1; assertThat("response code is 200", response.getStatus(), is(200)); - assertThat(response.getContent(), endsWith(failed_body)); assertHeader(response, "content-length", "6"); + byte content[] = response.getContentBytes(); + assertThat("content bytes", content.length, is(3)); + String contentStr = new String(content, StandardCharsets.UTF_8); + assertThat("content bytes as string", contentStr, is("foo")); } catch(EOFException e) {