diff --git a/Jenkinsfile b/Jenkinsfile index c241984244f..bfbf28a8a79 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,7 +89,6 @@ pipeline { } } - def slackNotif() { script { try { @@ -108,7 +107,6 @@ def slackNotif() { } } - /** * To other developers, if you are using this method above, please use the following syntax. * @@ -135,4 +133,5 @@ def mavenBuild(jdk, cmdline, mvnName, junitPublishDisabled) { } } + // vim: et:ts=2:sw=2:ft=groovy diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java index d3ac32dafbd..473fae972ab 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.websocket.javax.server.JavaxWebSocketServletContainerInitializer; +import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; /** * Example of setting up a javax.websocket server with Jetty embedded diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestSecurityAnnotationConversions.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestSecurityAnnotationConversions.java index b3975b1c4cb..3ff372e22ee 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestSecurityAnnotationConversions.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestSecurityAnnotationConversions.java @@ -173,7 +173,7 @@ public class TestSecurityAnnotationConversions public void testMethodAnnotation() throws Exception { //ServletSecurity annotation with HttpConstraint of TransportGuarantee.CONFIDENTIAL, and a list of rolesAllowed, and - //a HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default) + //an HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default) WebAppContext wac = makeWebAppContext(Method1Servlet.class.getCanonicalName(), "method1Servlet", new String[]{ "/foo/*", "*.foo" diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java index 248403bba03..d1648eb70d0 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java @@ -28,7 +28,7 @@ import org.eclipse.jetty.io.ClientConnectionFactory; * in order to plug-in a different transport for {@link HttpClient}. *

* While the {@link HttpClient} APIs define the HTTP semantic (request, response, headers, etc.) - * how a HTTP exchange is carried over the network depends on implementations of this class. + * how an HTTP exchange is carried over the network depends on implementations of this class. *

* The default implementation uses the HTTP protocol to carry over the network the HTTP exchange, * but the HTTP exchange may also be carried using the FCGI protocol, the HTTP/2 protocol or, diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java index efb5e983e4d..adb02176f0e 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java @@ -32,7 +32,7 @@ import org.eclipse.jetty.util.log.Logger; /** * {@link HttpContent} is a stateful, linear representation of the request content provided * by a {@link ContentProvider} that can be traversed one-way to obtain content buffers to - * send to a HTTP server. + * send to an HTTP server. *

* {@link HttpContent} offers the notion of a one-way cursor to traverse the content. * The cursor starts in a virtual "before" position and can be advanced using {@link #advance()} diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index daf6a32dca0..1f073351179 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -50,7 +50,7 @@ import org.eclipse.jetty.util.log.Logger; *

    *
  1. {@link #responseBegin(HttpExchange)}, when the HTTP response data containing the HTTP status code * is available
  2. - *
  3. {@link #responseHeader(HttpExchange, HttpField)}, when a HTTP field is available
  4. + *
  5. {@link #responseHeader(HttpExchange, HttpField)}, when an HTTP field is available
  6. *
  7. {@link #responseHeaders(HttpExchange)}, when all HTTP headers are available
  8. *
  9. {@link #responseContent(HttpExchange, ByteBuffer, Callback)}, when HTTP content is available
  10. *
  11. {@link #responseSuccess(HttpExchange)}, when the response is successful
  12. diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java index 6e5e330cf34..c883149027c 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java @@ -82,7 +82,7 @@ public class HttpRedirector /** * @param response the response to check for redirects - * @return whether the response code is a HTTP redirect code + * @return whether the response code is an HTTP redirect code */ public boolean isRedirect(Response response) { diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java index 9230088e738..a0d96182629 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java @@ -876,7 +876,7 @@ public class HttpRequest implements Request } catch (URISyntaxException x) { - // The "path" of a HTTP request may not be a URI, + // The "path" of an HTTP request may not be a URI, // for example for CONNECT 127.0.0.1:8080. return null; } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java index 9e872adb16c..a824e214392 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java @@ -40,7 +40,7 @@ import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.util.Fields; /** - *

    {@link Request} represents a HTTP request, and offers a fluent interface to customize + *

    {@link Request} represents an HTTP request, and offers a fluent interface to customize * various attributes such as the path, the headers, the content, etc.

    *

    You can create {@link Request} objects via {@link HttpClient#newRequest(String)} and * you can send them using either {@link #send()} for a blocking semantic, or diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java index 95605aad404..07e4d9b9a35 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java @@ -29,7 +29,7 @@ import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.util.Callback; /** - *

    {@link Response} represents a HTTP response and offers methods to retrieve status code, HTTP version + *

    {@link Response} represents an HTTP response and offers methods to retrieve status code, HTTP version * and headers.

    *

    {@link Response} objects are passed as parameters to {@link Response.Listener} callbacks, or as * future result of {@link Request#send()}.

    diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java index 9febba733de..d0a153c6c6f 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java @@ -161,7 +161,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res } /** - * Parses a HTTP response in the receivers buffer. + * Parses an HTTP response in the receivers buffer. * * @return true to indicate that parsing should be interrupted (and will be resumed by another thread). */ diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java index de20a500547..d04acf7dea1 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java @@ -485,7 +485,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest ContentResponse response = request .onResponseBegin(response1 -> { - // Simulate a HTTP 1.0 response has been received. + // Simulate an HTTP 1.0 response has been received. ((HttpResponse)response1).version(HttpVersion.HTTP_1_0); }) .send(); diff --git a/jetty-deploy/src/test/resources/jetty-http.xml b/jetty-deploy/src/test/resources/jetty-http.xml index 9526b56890a..137da33293f 100644 --- a/jetty-deploy/src/test/resources/jetty-http.xml +++ b/jetty-deploy/src/test/resources/jetty-http.xml @@ -3,13 +3,13 @@ - + - + diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java index 4d0614de153..d51238f9ceb 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java @@ -44,7 +44,7 @@ import org.eclipse.jetty.util.ProcessorUtils; /** * Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI. *

    - * This servlet accepts a HTTP request and transforms it into a FastCGI request + * This servlet accepts an HTTP request and transforms it into a FastCGI request * that is sent to the FastCGI server specified in the {@code proxyTo} * init-param. *

    diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/CookieCutter.java b/jetty-http/src/main/java/org/eclipse/jetty/http/CookieCutter.java index a5a4ac64952..d0ca77ba9d4 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/CookieCutter.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/CookieCutter.java @@ -64,15 +64,14 @@ public abstract class CookieCutter boolean inQuoted = false; boolean quoted = false; boolean escaped = false; + boolean reject = false; int tokenstart = -1; int tokenend = -1; for (int i = 0, length = hdr.length(); i <= length; i++) { char c = i == length ? 0 : hdr.charAt(i); - // System.err.printf("i=%d/%d c=%s v=%b q=%b/%b e=%b u=%s s=%d e=%d \t%s=%s%n" ,i,length,c==0?"|":(""+c),invalue,inQuoted,quoted,escaped,unquoted,tokenstart,tokenend,name,value); - - // Handle quoted values for name or value + // Handle quoted values for value if (inQuoted) { if (escaped) @@ -119,7 +118,7 @@ public abstract class CookieCutter // Handle name and value state machines if (invalue) { - // parse the value + // parse the cookie-value switch (c) { case ' ': @@ -193,7 +192,11 @@ public abstract class CookieCutter // This is a new cookie, so add the completed last cookie if we have one if (cookieName != null) { - addCookie(cookieName, cookieValue, cookieDomain, cookiePath, cookieVersion, cookieComment); + if (!reject) + { + addCookie(cookieName, cookieValue, cookieDomain, cookiePath, cookieVersion, cookieComment); + reject = false; + } cookieDomain = null; cookiePath = null; cookieComment = null; @@ -234,6 +237,15 @@ public abstract class CookieCutter quoted = false; continue; } + + if (_complianceMode == CookieCompliance.RFC6265) + { + if (isRFC6265RejectedCharacter(inQuoted, c)) + { + reject = true; + } + } + if (tokenstart < 0) tokenstart = i; tokenend = i; @@ -242,13 +254,26 @@ public abstract class CookieCutter } else { - // parse the name + // parse the cookie-name switch (c) { + case 0: case ' ': case '\t': continue; + case '"': + // Quoted name is not allowed in any version of the Cookie spec + reject = true; + break; + + case ';': + // a cookie terminated with no '=' sign. + tokenstart = -1; + invalue = false; + reject = false; + continue; + case '=': if (quoted) { @@ -272,6 +297,15 @@ public abstract class CookieCutter quoted = false; continue; } + + if (_complianceMode == CookieCompliance.RFC6265) + { + if (isRFC6265RejectedCharacter(inQuoted, c)) + { + reject = true; + } + } + if (tokenstart < 0) tokenstart = i; tokenend = i; @@ -281,7 +315,7 @@ public abstract class CookieCutter } } - if (cookieName != null) + if (cookieName != null && !reject) addCookie(cookieName, cookieValue, cookieDomain, cookiePath, cookieVersion, cookieComment); } } @@ -295,4 +329,31 @@ public abstract class CookieCutter } protected abstract void addCookie(String cookieName, String cookieValue, String cookieDomain, String cookiePath, int cookieVersion, String cookieComment); + + protected boolean isRFC6265RejectedCharacter(boolean inQuoted, char c) + { + if (inQuoted) + { + // We only reject if a Control Character is encountered + if (Character.isISOControl(c)) + { + return true; + } + } + else + { + /* From RFC6265 - Section 4.1.1 - Syntax + * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E + * ; US-ASCII characters excluding CTLs, + * ; whitespace DQUOTE, comma, semicolon, + * ; and backslash + */ + return Character.isISOControl(c) || // control characters + c > 127 || // 8-bit characters + c == ',' || // comma + c == ';'; // semicolon + } + + return false; + } } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HostPortHttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HostPortHttpField.java index 2379bcef99e..4b6128182fc 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HostPortHttpField.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HostPortHttpField.java @@ -21,7 +21,7 @@ package org.eclipse.jetty.http; import org.eclipse.jetty.util.HostPort; /** - * A HttpField holding a preparsed Host and port number + * An HttpField holding a preparsed Host and port number * * @see HostPort */ diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java index e69af07893f..21425329ded 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java @@ -23,7 +23,7 @@ import java.util.Objects; import org.eclipse.jetty.util.StringUtil; /** - * A HTTP Field + * An HTTP Field */ public class HttpField { diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java index 741be954df5..016f3dcbbee 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java @@ -48,7 +48,7 @@ public enum HttpMethod * @param bytes Array containing ISO-8859-1 characters * @param position The first valid index * @param limit The first non valid index - * @return A HttpMethod if a match or null if no easy match. + * @return An HttpMethod if a match or null if no easy match. */ public static HttpMethod lookAheadGet(byte[] bytes, final int position, int limit) { @@ -110,7 +110,7 @@ public enum HttpMethod * Optimized lookup to find a method name and trailing space in a byte array. * * @param buffer buffer containing ISO-8859-1 characters, it is not modified. - * @return A HttpMethod if a match or null if no easy match. + * @return An HttpMethod if a match or null if no easy match. */ public static HttpMethod lookAheadGet(ByteBuffer buffer) { diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 26ef2ca2337..1093feae375 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -442,7 +442,7 @@ public class HttpParser return t; } - /* Quick lookahead for the start state looking for a request method or a HTTP version, + /* Quick lookahead for the start state looking for a request method or an HTTP version, * otherwise skip white space until something else to parse. */ private boolean quickStart(ByteBuffer buffer) @@ -1834,14 +1834,14 @@ public class HttpParser boolean messageComplete(); /** - * This is the method called by parser when a HTTP Header name and value is found + * This is the method called by parser when an HTTP Header name and value is found * * @param field The field parsed */ void parsedHeader(HttpField field); /** - * This is the method called by parser when a HTTP Trailer name and value is found + * This is the method called by parser when an HTTP Trailer name and value is found * * @param field The field parsed */ @@ -1851,7 +1851,7 @@ public class HttpParser /** * Called to signal that an EOF was received unexpectedly - * during the parsing of a HTTP message + * during the parsing of an HTTP message */ void earlyEOF(); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java index 58d2a98f4bd..e48b37d84fc 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java @@ -314,6 +314,20 @@ public class HttpStatus } } + public static boolean hasNoBody(int status) + { + switch (status) + { + case NO_CONTENT_204: + case NOT_MODIFIED_304: + case PARTIAL_CONTENT_206: + return true; + + default: + return status < OK_200; + } + } + /** * Simple test against an code to determine if it falls into the * Informational message category as defined in the http://user@host:port/path/info;param?query#fragment * this class will split it into the following undecoded optional elements: