diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 2189d3bb75c..2ed6b82ff93 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -100,7 +100,7 @@ war true ** - ${assembly-directory}/webapps + ${assembly-directory}/webapps.demo test.war @@ -110,7 +110,7 @@ war true ** - ${assembly-directory}/webapps + ${assembly-directory}/webapps.demo xref-proxy.war @@ -120,7 +120,7 @@ war true ** - ${assembly-directory}/webapps + ${assembly-directory}/webapps.demo async-rest.war diff --git a/jetty-distribution/src/main/resources/start.d/000-jvm.ini.disabled b/jetty-distribution/src/main/resources/start.d/000-jvm.ini.disabled new file mode 100644 index 00000000000..1f5e32946c2 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/000-jvm.ini.disabled @@ -0,0 +1,21 @@ +#=========================================================== +# Configure JVM arguments. +#----------------------------------------------------------- +--exec + +-Xmx2000m +-Xmn512m +-XX:+UseConcMarkSweepGC +-XX:ParallelCMSThreads=2 +-XX:+CMSClassUnloadingEnabled +-XX:+UseCMSCompactAtFullCollection +-XX:CMSInitiatingOccupancyFraction=80 +# -verbose:gc +# -XX:+PrintGCDateStamps +# -XX:+PrintGCTimeStamps +# -XX:+PrintGCDetails +# -XX:+PrintTenuringDistribution +# -XX:+PrintCommandLineFlags +# -XX:+DisableExplicitGC + +# -Dorg.apache.jasper.compiler.disablejsr199=true diff --git a/jetty-distribution/src/main/resources/start.d/100-jetty.ini b/jetty-distribution/src/main/resources/start.d/100-jetty.ini new file mode 100644 index 00000000000..cbd5f75a20f --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/100-jetty.ini @@ -0,0 +1,16 @@ +#=========================================================== +# Default Server Options +# Use the core server jars with websocket on the classpath +# Add the contents of the resources directory to the classpath +# Add jars discovered in lib/ext to the classpath +# Include the core jetty configuration file +#----------------------------------------------------------- +OPTIONS=Server,websocket,resources,ext +threads.min=10 +threads.max=200 +threads.timeout=60000 +#jetty.host=myhost.com +jetty.dump.start=false +jetty.dump.stop=false + +etc/jetty.xml diff --git a/jetty-distribution/src/main/resources/start.d/110-jmx.ini b/jetty-distribution/src/main/resources/start.d/110-jmx.ini new file mode 100644 index 00000000000..ce176332b2d --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/110-jmx.ini @@ -0,0 +1,10 @@ +#=========================================================== +# JMX Management +# To enable remote JMX access uncomment jmxremote and +# enable --exec +#----------------------------------------------------------- +OPTIONS=jmx +# jetty.jmxrmihost=localhost +# jetty.jmxrmiport=1099 +# -Dcom.sun.management.jmxremote +etc/jetty-jmx.xml diff --git a/jetty-distribution/src/main/resources/start.d/110-jsp.ini b/jetty-distribution/src/main/resources/start.d/110-jsp.ini new file mode 100644 index 00000000000..525fb6214b8 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/110-jsp.ini @@ -0,0 +1,5 @@ +#=========================================================== +# Java Server Pages +#----------------------------------------------------------- +OPTIONS=jsp + diff --git a/jetty-distribution/src/main/resources/start.d/110-logging.ini.disabled b/jetty-distribution/src/main/resources/start.d/110-logging.ini.disabled new file mode 100644 index 00000000000..c8dfa64da1a --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/110-logging.ini.disabled @@ -0,0 +1,7 @@ +#=========================================================== +# Server logging. +# The following configuration will redirect stderr and stdout +# to file which is rolled over daily. +#----------------------------------------------------------- +jetty.log.retain=90 +etc/jetty-logging.xml diff --git a/jetty-distribution/src/main/resources/start.d/110-setuid.ini.disabled b/jetty-distribution/src/main/resources/start.d/110-setuid.ini.disabled new file mode 100644 index 00000000000..97b1682ced3 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/110-setuid.ini.disabled @@ -0,0 +1,13 @@ +#=========================================================== +# Enable SetUID +# The default user and group is 'jetty' and if you are +# starting as root you must change the run privledged to true +#----------------------------------------------------------- +OPTIONS=setuid +jetty.startServerAsPrivileged=false +jetty.username=jetty +jetty.groupname=jetty +jetty.umask=002 + +etc/jetty-setuid.xml + diff --git a/jetty-distribution/src/main/resources/start.d/200-npn.ini.disabled b/jetty-distribution/src/main/resources/start.d/200-npn.ini.disabled new file mode 100644 index 00000000000..0ca98db0fd6 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/200-npn.ini.disabled @@ -0,0 +1,12 @@ +#=========================================================== +# NPN Next Protocol Negotiation +# +# The SPDY and HTTP/2.0 connectors require NPN. The jar for +# NPN cannot be downloaded from eclipse. So the --download +# option is used to install the NPN jar if it does not already +# exist +# +#----------------------------------------------------------- +--exec +--download=http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar +-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar diff --git a/jetty-distribution/src/main/resources/start.d/200-ssl.ini.disabled b/jetty-distribution/src/main/resources/start.d/200-ssl.ini.disabled new file mode 100644 index 00000000000..6a56dd54e65 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/200-ssl.ini.disabled @@ -0,0 +1,12 @@ +#=========================================================== +# SSL Context +# For use by HTTPS and SPDY +#----------------------------------------------------------- +jetty.keystore=etc/keystore +jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 +jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g +jetty.truststore=etc/keystore +jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 +jetty.secure.port=8443 + +etc/jetty-ssl.xml diff --git a/jetty-distribution/src/main/resources/start.d/210-http.ini b/jetty-distribution/src/main/resources/start.d/210-http.ini new file mode 100644 index 00000000000..ee8133306c3 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/210-http.ini @@ -0,0 +1,6 @@ +#=========================================================== +# HTTP Connector +#----------------------------------------------------------- +jetty.port=8080 +http.timeout=30000 +etc/jetty-http.xml diff --git a/jetty-distribution/src/main/resources/start.d/210-https.ini.disabled b/jetty-distribution/src/main/resources/start.d/210-https.ini.disabled new file mode 100644 index 00000000000..42897c42da4 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/210-https.ini.disabled @@ -0,0 +1,6 @@ +#=========================================================== +# HTTPS Connector +# Must be used with 200-ssl.ini +#----------------------------------------------------------- +jetty.https.port=8443 +etc/jetty-https.xml diff --git a/jetty-distribution/src/main/resources/start.d/210-spdy.ini.disabled b/jetty-distribution/src/main/resources/start.d/210-spdy.ini.disabled new file mode 100644 index 00000000000..0d0eac46911 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/210-spdy.ini.disabled @@ -0,0 +1,9 @@ +#=========================================================== +# SPDY Connector +# Must be used with 200-ssl.ini and 200-npn.ini +#----------------------------------------------------------- +OPTIONS=spdy +jetty.spdy.port=8443 + +etc/jetty-spdy.xml + diff --git a/jetty-distribution/src/main/resources/start.d/300-plus.ini.disabled b/jetty-distribution/src/main/resources/start.d/300-plus.ini.disabled new file mode 100644 index 00000000000..021c48a7847 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/300-plus.ini.disabled @@ -0,0 +1,8 @@ +#=========================================================== +# Annotations JNDI JAAS processing +#----------------------------------------------------------- +OPTIONS=plus +etc/jetty-plus.xml +OPTIONS=annotations +etc/jetty-annotations.xml + diff --git a/jetty-distribution/src/main/resources/start.d/300-requestlog.ini.disabled b/jetty-distribution/src/main/resources/start.d/300-requestlog.ini.disabled new file mode 100644 index 00000000000..195d2b94687 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/300-requestlog.ini.disabled @@ -0,0 +1,9 @@ +#=========================================================== +# Request logger +# Will add a handler to log all HTTP requests to a standard +# request log format file. +#----------------------------------------------------------- +requestlog.retain=90 +requestlog.append=true +requestlog.extended=true +etc/jetty-requestlog.xml diff --git a/jetty-distribution/src/main/resources/start.d/400-debug.ini.disabled b/jetty-distribution/src/main/resources/start.d/400-debug.ini.disabled new file mode 100644 index 00000000000..d2f69bb8101 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/400-debug.ini.disabled @@ -0,0 +1 @@ +etc/jetty-debug.xml diff --git a/jetty-distribution/src/main/resources/start.d/400-ipaccess.ini.disabled b/jetty-distribution/src/main/resources/start.d/400-ipaccess.ini.disabled new file mode 100644 index 00000000000..d272540be4f --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/400-ipaccess.ini.disabled @@ -0,0 +1 @@ +etc/jetty-ipaccess.xml diff --git a/jetty-distribution/src/main/resources/start.d/400-lowresources.ini.disabled b/jetty-distribution/src/main/resources/start.d/400-lowresources.ini.disabled new file mode 100644 index 00000000000..c6847804e8a --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/400-lowresources.ini.disabled @@ -0,0 +1,11 @@ +#=========================================================== +#----------------------------------------------------------- + +lowresources.period=1050 +lowresources.lowResourcesIdleTimeout=200 +lowresources.monitorThreads=true +lowresources.maxConnections=0 +lowresources.maxMemory=0 +lowresources.maxLowResourcesTime=5000 +etc/jetty-lowresources.xml + diff --git a/jetty-distribution/src/main/resources/start.d/400-stats.ini.disabled b/jetty-distribution/src/main/resources/start.d/400-stats.ini.disabled new file mode 100644 index 00000000000..1f09e7d70a3 --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/400-stats.ini.disabled @@ -0,0 +1,4 @@ +#=========================================================== +#----------------------------------------------------------- +etc/jetty-stats.xml + diff --git a/jetty-distribution/src/main/resources/start.d/500-deploy.ini b/jetty-distribution/src/main/resources/start.d/500-deploy.ini new file mode 100644 index 00000000000..11e7f03a14b --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/500-deploy.ini @@ -0,0 +1,4 @@ +#=========================================================== +# Webapplication Deployer +#----------------------------------------------------------- +etc/jetty-deploy.xml diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 382010d19b3..9a5b1e2924f 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -1,5 +1,6 @@ #=========================================================== # Jetty start.jar arguments +# # The contents of this file, together with the start.ini # fragments found in start.d directory are used to build # the classpath and command line on a call to @@ -23,199 +24,8 @@ # #=========================================================== -#=========================================================== -# The --exec option should be used if any of the JVM options -# in this file are uncommented (eg -D* or -X*). Because a -# JVM cannot change it's own options, the --exec flag causes -# start.jar to fork a new JVM with the requested arguments. -# -# Alternately, a command line may be generated by running -# -# java -jar start.jar --exec-print -# -# and the results executed to start the jetty server. -# For example --exec can be avoided if jetty is started on unix with -# -# eval $(java -jar start.jar --exec-print) -# -#----------------------------------------------------------- -# --exec -#=========================================================== - -#=========================================================== -# Configure Properties. -# The properties defined here may be used by the -# element in the XML files -# passed to start.jar. -# Alternately a file ending with ".properties" can be -# added that will include multiple properties. -# Properties, unlike SystemProperties, do not need --exec -# to be specified. -#----------------------------------------------------------- -# jetty.home=. -# jetty.logs=./logs -# jetty.host=0.0.0.0 -#=========================================================== - - -#=========================================================== -# Configure JVM arguments. -# Must be used with --exec or --exec-print -#----------------------------------------------------------- -# -Dorg.apache.jasper.compiler.disablejsr199=true -# -Xmx2000m -# -Xmn512m -# -verbose:gc -# -XX:+PrintGCDateStamps -# -XX:+PrintGCTimeStamps -# -XX:+PrintGCDetails -# -XX:+PrintTenuringDistribution -# -XX:+PrintCommandLineFlags -# -XX:+DisableExplicitGC -# -XX:+UseConcMarkSweepGC -# -XX:ParallelCMSThreads=2 -# -XX:+CMSClassUnloadingEnabled -# -XX:+UseCMSCompactAtFullCollection -# -XX:CMSInitiatingOccupancyFraction=80 -#=========================================================== - -#=========================================================== -# Default Server Options -# Use the core server jars with websocket on the classpath -# Add the contents of the resources directory to the classpath -# Add jars discovered in lib/ext to the classpath -# Include the core jetty configuration file -#----------------------------------------------------------- -OPTIONS=Server,websocket,resources,ext -etc/jetty.xml -#=========================================================== - -#=========================================================== -# Enable SetUID -# The default user and group is 'jetty' and if you are -# starting as root you must change the run privledged to true -#----------------------------------------------------------- -# OPTIONS=setuid -# etc/jetty-setuid.xml -# jetty.startServerAsPrivileged=false -# jetty.username=jetty -# jetty.groupname=jetty -# jetty.umask=002 -#=========================================================== - -#=========================================================== -# Server logging. -# The following configuration will redirect stderr and stdout -# to file which is rolled over daily. -#----------------------------------------------------------- -# etc/jetty-logging.xml -#=========================================================== - -#=========================================================== -# JMX Management -# To enable remote JMX access uncomment jmxremote and -# enable --exec or use --exec-print (see above) -#----------------------------------------------------------- -OPTIONS=jmx -# jetty.jmxrmihost=localhost -# jetty.jmxrmiport=1099 -# -Dcom.sun.management.jmxremote -etc/jetty-jmx.xml -#=========================================================== - -#=========================================================== -# Java Server Pages -#----------------------------------------------------------- -OPTIONS=jsp -#=========================================================== - - -#=========================================================== -# Annotations JNDI JAAS processing -#----------------------------------------------------------- -# OPTIONS=plus -# etc/jetty-plus.xml -# OPTIONS=annotations -# etc/jetty-annotations.xml -#=========================================================== - -#=========================================================== -# HTTP Connector -#----------------------------------------------------------- -# jetty.port=8080 -etc/jetty-http.xml -#=========================================================== - -#=========================================================== -# SSL Context -# For use by HTTPS and SPDY -#----------------------------------------------------------- -# jetty.keystore=etc/keystore -# jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 -# jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g -# jetty.truststore=etc/keystore -# jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 -# jetty.secure.port=8443 -# etc/jetty-ssl.xml -#=========================================================== - -#=========================================================== -# HTTPS Connector -#----------------------------------------------------------- -# jetty.https.port=8443 -# etc/jetty-https.xml -#=========================================================== - -#=========================================================== -# SPDY Connector -# -# SPDY requires the NPN jar which must be separately downloaded: -# -# http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar -# -# Which should be saved in lib/npn-boot-1.1.5.v20130313.jar -# -# To include the NPN jar on the boot path, you must either: -# -# a) enable --exec above and uncomment the -Xbootclass line -# below -# -# b) Add -Xbootclasspath/p:lib/npn-boot-1.1.5.v20130313.jar -# to the command line when running jetty. -# -#----------------------------------------------------------- -# OPTIONS=spdy -# -Xbootclasspath/p:lib/npn-boot-1.1.5.v20130313.jar -# jetty.spdy.port=8443 -# etc/jetty-spdy.xml -#=========================================================== - -#=========================================================== -# Webapplication Deployer -#----------------------------------------------------------- -etc/jetty-deploy.xml -#=========================================================== - -#=========================================================== -# Request logger -# Will add a handler to log all HTTP requests to a standard -# request log format file. -#----------------------------------------------------------- -etc/jetty-requestlog.xml -#=========================================================== - -#=========================================================== -# Additional configurations -# See headers of individual files for explanations -#----------------------------------------------------------- -# etc/jetty-stats.xml -# etc/jetty-debug.xml -# etc/jetty-ipaccess.xml -# etc/jetty-lowresources.xml -#=========================================================== - -#=========================================================== -# Lookup additional ini files in start.d -#----------------------------------------------------------- +# The start.d directory contains the active start.ini fragments start.d/ -#=========================================================== + +# More start.ini fragments are in files named start.d/*.ini.disabled +# They may be enabled by moving, linking or copying to *.ini files. diff --git a/jetty-distribution/src/main/resources/webapps.demo/README.TXT b/jetty-distribution/src/main/resources/webapps.demo/README.TXT new file mode 100644 index 00000000000..ec2bea255cb --- /dev/null +++ b/jetty-distribution/src/main/resources/webapps.demo/README.TXT @@ -0,0 +1,7 @@ + +This directory is scanned by the demo WebAppDeployer provider +created in the etc/jetty-demo.xml file and enabled by the +start.d/900-demo.ini file. + +For normal deployment, use the webapps directory. + diff --git a/jetty-distribution/src/main/resources/webapps/ROOT/images/jetty-header.jpg b/jetty-distribution/src/main/resources/webapps.demo/ROOT/images/jetty-header.jpg similarity index 100% rename from jetty-distribution/src/main/resources/webapps/ROOT/images/jetty-header.jpg rename to jetty-distribution/src/main/resources/webapps.demo/ROOT/images/jetty-header.jpg diff --git a/jetty-distribution/src/main/resources/webapps/ROOT/images/webtide_logo.jpg b/jetty-distribution/src/main/resources/webapps.demo/ROOT/images/webtide_logo.jpg similarity index 100% rename from jetty-distribution/src/main/resources/webapps/ROOT/images/webtide_logo.jpg rename to jetty-distribution/src/main/resources/webapps.demo/ROOT/images/webtide_logo.jpg diff --git a/jetty-distribution/src/main/resources/webapps/ROOT/index.html b/jetty-distribution/src/main/resources/webapps.demo/ROOT/index.html similarity index 100% rename from jetty-distribution/src/main/resources/webapps/ROOT/index.html rename to jetty-distribution/src/main/resources/webapps.demo/ROOT/index.html diff --git a/jetty-distribution/src/main/resources/webapps/ROOT/jetty.css b/jetty-distribution/src/main/resources/webapps.demo/ROOT/jetty.css similarity index 100% rename from jetty-distribution/src/main/resources/webapps/ROOT/jetty.css rename to jetty-distribution/src/main/resources/webapps.demo/ROOT/jetty.css diff --git a/jetty-distribution/src/main/resources/webapps/example-moved.xml b/jetty-distribution/src/main/resources/webapps.demo/example-moved.xml similarity index 100% rename from jetty-distribution/src/main/resources/webapps/example-moved.xml rename to jetty-distribution/src/main/resources/webapps.demo/example-moved.xml diff --git a/jetty-distribution/src/main/resources/webapps/javadoc.xml b/jetty-distribution/src/main/resources/webapps.demo/javadoc.xml similarity index 100% rename from jetty-distribution/src/main/resources/webapps/javadoc.xml rename to jetty-distribution/src/main/resources/webapps.demo/javadoc.xml diff --git a/jetty-distribution/src/main/resources/webapps/.donotdelete b/jetty-distribution/src/main/resources/webapps/.donotdelete deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/jetty-server/src/main/config/etc/jetty-http.xml b/jetty-server/src/main/config/etc/jetty-http.xml index 731304e7a28..7ae3064a098 100644 --- a/jetty-server/src/main/config/etc/jetty-http.xml +++ b/jetty-server/src/main/config/etc/jetty-http.xml @@ -33,7 +33,7 @@ - 30000 + diff --git a/jetty-server/src/main/config/etc/jetty-lowresources.xml b/jetty-server/src/main/config/etc/jetty-lowresources.xml index 5b264f1749f..060919a8d3c 100644 --- a/jetty-server/src/main/config/etc/jetty-lowresources.xml +++ b/jetty-server/src/main/config/etc/jetty-lowresources.xml @@ -10,12 +10,12 @@ - 1000 - 200 - true - 0 - 0 - 5000 + + + + + + diff --git a/jetty-server/src/main/config/etc/jetty-requestlog.xml b/jetty-server/src/main/config/etc/jetty-requestlog.xml index 6e6eb054f0c..213177731a2 100644 --- a/jetty-server/src/main/config/etc/jetty-requestlog.xml +++ b/jetty-server/src/main/config/etc/jetty-requestlog.xml @@ -17,9 +17,9 @@ /yyyy_mm_dd.request.log yyyy_MM_dd - 90 - true - true + + + false GMT diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml index 42b80a31140..a551326cc6a 100644 --- a/jetty-server/src/main/config/etc/jetty.xml +++ b/jetty-server/src/main/config/etc/jetty.xml @@ -44,9 +44,9 @@ - 10 - 200 - 60000 + + + false diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 0be66d81cf9..f3931206d34 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -50,6 +50,8 @@ import java.util.Locale; import java.util.Properties; import java.util.Set; +import javax.naming.OperationNotSupportedException; + /*-------------------------------------------*/ /** *

@@ -175,6 +177,12 @@ public class Main stop(port,key,timeout); return null; } + + if (arg.startsWith("--download=")) + { + download(arg); + continue; + } if ("--version".equals(arg) || "-v".equals(arg) || "--info".equals(arg)) { @@ -302,6 +310,121 @@ public class Main return xmls; } + private void download(String arg) + { + try + { + String[] split = arg.split(":",3); + if (split.length!=3 || "http".equalsIgnoreCase(split[0]) || !split[1].startsWith("//")) + throw new IllegalArgumentException("Not --download=:"); + + String location=split[2]; + if (File.separatorChar!='/') + location.replaceAll("/",File.separator); + File file = new File(location); + + if (Config.isDebug()) + System.err.println("Download to "+file.getAbsolutePath()+(file.exists()?" Exists!":"")); + if (file.exists()) + return; + + String[] parse = split[1].split("/",4); + String host=parse[2]; + String uri="/"+split[1].substring(3+host.length()); + + try (Socket socket = new Socket(host,80)) + { + String request="GET "+uri+" HTTP/1.0\r\n"+ + "Host: "+host+"\r\n"+ + "User-Agent: jetty-start.jar\r\n"+ + "\r\n"; + + socket.getOutputStream().write(request.getBytes("ISO-8859-1")); + socket.getOutputStream().flush(); + + InputStream in = socket.getInputStream(); + + int state=0; + loop: while (state>=0) + { + char c = (char)in.read(); + + switch (state) + { + case 0: + c=Character.toLowerCase(c); + if (c==' ') + state=1; + else if (c!='h' && c!='t' && c!='p' && c!='/' && c!='.' && !Character.isDigit(c)) + break loop; + break; + case 1: + if (c==' ') + state=2; + else if (c!='2' && c!='0') + break loop; + break; + case 2: + if (c=='\r') + state=3; + else if (c=='\n') + state=4; + break; + case 3: + if (c=='\n') + state=4; + else if (c=='\r') + state=-1; + break; + + case 4: + if (c=='\r') + state=5; + else if (c=='\n') + state=-1; + else + state=2; + break; + + case 5: + if (c=='\n') + state=-1; + else + state=2; + break; + } + } + + if (state>=0) + throw new IOException("Bad HTTP response: "+state); + + System.err.println("DOWNLOAD: "+uri+" from "+host+" to "+location); + if (!file.getParentFile().exists()) + file.getParentFile().mkdirs(); + + byte[] buf=new byte[8192]; + try (OutputStream out = new FileOutputStream(file)) + { + while(!socket.isInputShutdown()) + { + int len = in.read(buf); + + if (len>0) + out.write(buf,0,len); + if (len<0) + break; + } + } + } + } + catch(Exception e) + { + System.err.println("ERROR: processing "+arg+"\n"+e); + e.printStackTrace(); + usageExit(EXIT_USAGE); + } + } + private void usage() { String usageResource = "org/eclipse/jetty/start/usage.txt"; diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt index 7272c5f674c..e25a73d277c 100644 --- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt +++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt @@ -45,6 +45,10 @@ Command Line Options: and additional .ini files in jetty.home/start.d/ will NOT be read. A --ini option with no file indicates that start.ini should not be read. + + --download=:location + If the file does not exist at the given location, then + download it from the given http URI System Properties: These are set with a command line like "java -Dname=value ..." and are diff --git a/tests/test-webapps/test-jaas-webapp/src/main/config/webapps/test-jaas.xml b/tests/test-webapps/test-jaas-webapp/src/main/config/webapps.demo/test-jaas.xml similarity index 100% rename from tests/test-webapps/test-jaas-webapp/src/main/config/webapps/test-jaas.xml rename to tests/test-webapps/test-jaas-webapp/src/main/config/webapps.demo/test-jaas.xml diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/etc/jetty-demo.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/etc/jetty-demo.xml new file mode 100644 index 00000000000..938e7cf213d --- /dev/null +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/etc/jetty-demo.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + /webapps.demo + /etc/webdefault.xml + 1 + true + + + + + + + diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/start.d/test-webapp.ini b/tests/test-webapps/test-jetty-webapp/src/main/config/start.d/900-demo.ini similarity index 83% rename from tests/test-webapps/test-jetty-webapp/src/main/config/start.d/test-webapp.ini rename to tests/test-webapps/test-jetty-webapp/src/main/config/start.d/900-demo.ini index 2c4006b6bc7..95e58b53ae5 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/start.d/test-webapp.ini +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/start.d/900-demo.ini @@ -1,3 +1,4 @@ # Enabled services and configuration needed by the test webapp OPTIONS=client etc/test-realm.xml +etc/jetty-demo.xml diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.d/override-web.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/webapps.demo/test.d/override-web.xml similarity index 100% rename from tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.d/override-web.xml rename to tests/test-webapps/test-jetty-webapp/src/main/config/webapps.demo/test.d/override-web.xml diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/webapps.demo/test.xml similarity index 92% rename from tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.xml rename to tests/test-webapps/test-jetty-webapp/src/main/config/webapps.demo/test.xml index ff7eb6b8056..44cbce55c37 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.xml +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/webapps.demo/test.xml @@ -19,15 +19,15 @@ detected. /test - /webapps/test.war + /test.war true false - /etc/webdefault.xml - /webapps/test.d/override-web.xml + /etc/webdefault.xml + /test.d/override-web.xml