diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java index eb889e56a32..ebeb5fddf92 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java @@ -31,7 +31,7 @@ public enum HttpVersion HTTP_0_9("HTTP/0.9",9), HTTP_1_0("HTTP/1.0",10), HTTP_1_1("HTTP/1.1",11), - HTTP_2_0("HTTP/2.0",20); + HTTP_2("HTTP/2",20); /* ------------------------------------------------------------ */ public final static Trie CACHE= new ArrayTrie(); @@ -74,7 +74,7 @@ public enum HttpVersion switch(bytes[position+7]) { case '0': - return HTTP_2_0; + return HTTP_2; } break; } diff --git a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/HeadersGenerateParseTest.java b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/HeadersGenerateParseTest.java index 38aa07281a7..b9291a020ff 100644 --- a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/HeadersGenerateParseTest.java +++ b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/HeadersGenerateParseTest.java @@ -51,7 +51,7 @@ public class HeadersGenerateParseTest HttpFields fields = new HttpFields(); fields.put("Accept", "text/html"); fields.put("User-Agent", "Jetty"); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); // Iterate a few times to be sure generator and parser are properly reset. final List frames = new ArrayList<>(); @@ -105,7 +105,7 @@ public class HeadersGenerateParseTest HttpFields fields = new HttpFields(); fields.put("Accept", "text/html"); fields.put("User-Agent", "Jetty"); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); final List frames = new ArrayList<>(); ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); diff --git a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/PushPromiseGenerateParseTest.java b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/PushPromiseGenerateParseTest.java index 7ebc775545c..17620380e61 100644 --- a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/PushPromiseGenerateParseTest.java +++ b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/frames/PushPromiseGenerateParseTest.java @@ -52,7 +52,7 @@ public class PushPromiseGenerateParseTest HttpFields fields = new HttpFields(); fields.put("Accept", "text/html"); fields.put("User-Agent", "Jetty"); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); // Iterate a few times to be sure generator and parser are properly reset. final List frames = new ArrayList<>(); @@ -107,7 +107,7 @@ public class PushPromiseGenerateParseTest HttpFields fields = new HttpFields(); fields.put("Accept", "text/html"); fields.put("User-Agent", "Jetty"); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields); final List frames = new ArrayList<>(); ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java index 94f4c55c036..fe7b63a6f43 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java @@ -107,10 +107,10 @@ public class MetaDataBuilder HttpFields fields = _fields; _fields = new HttpFields(Math.max(10,fields.size()+5)); if (_method!=null) - return new MetaData.Request(HttpVersion.HTTP_2_0,_scheme,_method,_authority,_host,_port,_path,fields); + return new MetaData.Request(HttpVersion.HTTP_2,_scheme,_method,_authority,_host,_port,_path,fields); if (_status!=0) - return new MetaData.Response(HttpVersion.HTTP_2_0,_status,fields); - return new MetaData(HttpVersion.HTTP_2_0,fields); + return new MetaData.Response(HttpVersion.HTTP_2,_status,fields); + return new MetaData(HttpVersion.HTTP_2,fields); } finally { diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java index fa5669c88fd..7ca1dd521ec 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java @@ -70,7 +70,7 @@ public class HpackEncoderTest // encode them ByteBuffer buffer = BufferUtil.allocate(4096); int pos = BufferUtil.flipToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,pos); // something was encoded! @@ -89,7 +89,7 @@ public class HpackEncoderTest // encode exact same fields again! BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // nothing should be encoded! @@ -112,7 +112,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -136,7 +136,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -163,7 +163,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -191,7 +191,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -225,7 +225,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -246,7 +246,7 @@ public class HpackEncoderTest // encode BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! @@ -258,7 +258,7 @@ public class HpackEncoderTest // encode again BufferUtil.clearToFill(buffer); - encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2_0,fields)); + encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); // something was encoded! diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java index 63a1dff5306..a088cec5abc 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java @@ -46,7 +46,7 @@ public class HpackTest fields0.add(HttpHeader.SERVER,"jetty"); fields0.add(HttpHeader.SET_COOKIE,"abcdefghijklmnopqrstuvwxyz"); fields0.add("custom-key","custom-value"); - Response original0 = new Response(HttpVersion.HTTP_2_0,200,fields0); + Response original0 = new Response(HttpVersion.HTTP_2,200,fields0); BufferUtil.clearToFill(buffer); encoder.encode(buffer,original0); @@ -68,7 +68,7 @@ public class HpackTest fields1.add(HttpHeader.CONTENT_LENGTH,"1234"); fields1.add(HttpHeader.SERVER,"jetty"); fields1.add("custom-key","other-value"); - Response original1 = new Response(HttpVersion.HTTP_2_0,200,fields1); + Response original1 = new Response(HttpVersion.HTTP_2,200,fields1); // Same again? BufferUtil.clearToFill(buffer); diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java index 8f3fcd6dd59..9beebceb946 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java @@ -82,10 +82,10 @@ public class HttpTransportOverHTTP2 implements HttpTransport if (LOG.isDebugEnabled()) { LOG.debug("HTTP2 Response #{}:{}{} {}{}{}", - stream.getId(), System.lineSeparator(), HttpVersion.HTTP_2_0, info.getStatus(), System.lineSeparator(), info.getHttpFields()); + stream.getId(), System.lineSeparator(), HttpVersion.HTTP_2, info.getStatus(), System.lineSeparator(), info.getHttpFields()); } - MetaData metaData = new MetaData.Response(HttpVersion.HTTP_2_0, info.getStatus(), info.getHttpFields()); + MetaData metaData = new MetaData.Response(HttpVersion.HTTP_2, info.getStatus(), info.getHttpFields()); HeadersFrame frame = new HeadersFrame(stream.getId(), metaData, null, endStream); stream.headers(frame, callback); } diff --git a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java index 2869c3b9350..7405d9aac51 100644 --- a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java +++ b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java @@ -105,7 +105,7 @@ public class HTTP2ServerTest String host = "localhost"; int port = connector.getLocalPort(); HttpFields fields = new HttpFields(); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, HttpMethod.GET.asString(), + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(), host + ":" + port, host, port, path, fields); HeadersFrame request = new HeadersFrame(1, metaData, null, true); ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); @@ -154,7 +154,7 @@ public class HTTP2ServerTest String host = "localhost"; int port = connector.getLocalPort(); HttpFields fields = new HttpFields(); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0, HttpScheme.HTTP, HttpMethod.GET.asString(), + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(), host + ":" + port, host, port, path, fields); HeadersFrame request = new HeadersFrame(1, metaData, null, true); ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); @@ -217,7 +217,7 @@ public class HTTP2ServerTest String host = "localhost"; int port = connector.getLocalPort(); HttpFields fields = new HttpFields(); - MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2_0,HttpScheme.HTTP, HttpMethod.GET.asString(), + MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2,HttpScheme.HTTP, HttpMethod.GET.asString(), host + ":" + port, host, port, path, fields); HeadersFrame request = new HeadersFrame(1, metaData, null, true); ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); diff --git a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/Http2Server.java b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/Http2Server.java index e5965e2d50f..35eb759dc2d 100644 --- a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/Http2Server.java +++ b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/Http2Server.java @@ -94,7 +94,7 @@ public class Http2Server // SSL Factory SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,alpn.getProtocol()); - // SPDY Connector + // HTTP2 Connector ServerConnector http2Connector = new ServerConnector(server,ssl,alpn,h2,new HttpConnectionFactory(https_config)); http2Connector.setPort(8443); @@ -118,7 +118,7 @@ public class Http2Server HttpSession session = request.getSession(true); response.setHeader("custom","value"); response.setContentType("text/plain"); - String content = "Hello from Jetty HTTP2\n"; + String content = "Hello from Jetty using "+request.getProtocol() +"\n"; content+="uri="+request.getRequestURI()+"\n"; content+="session="+session.getId()+(session.isNew()?"(New)\n":"\n"); content+="date="+new Date()+"\n";