From 116d654426c4cdf0da51bb3a537c2d4e99529a31 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 12 Jun 2014 15:08:46 +0200 Subject: [PATCH] cleaned up debug --- .../org/eclipse/jetty/http2/hpack/AuthorityHttpField.java | 6 ++++++ .../java/org/eclipse/jetty/http2/hpack/HpackEncoder.java | 8 ++++---- .../eclipse/jetty/http2/hpack/StaticValueHttpField.java | 6 ++++++ .../org/eclipse/jetty/http2/hpack/HpackContextTest.java | 2 ++ .../java/org/eclipse/jetty/http2/server/Http2Server.java | 7 ++++++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/AuthorityHttpField.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/AuthorityHttpField.java index 121788b66cb..99bdf14593d 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/AuthorityHttpField.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/AuthorityHttpField.java @@ -35,4 +35,10 @@ public class AuthorityHttpField extends HostPortHttpField { super(null,AUTHORITY,authority); } + + @Override + public String toString() + { + return String.format("%s(preparsed h=%s p=%d)",super.toString(),getHost(),getPort()); + } } diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java index 42e912d6181..5345050f6ad 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java @@ -287,10 +287,10 @@ public class HpackEncoder if (p>=0) { - encoding="Literal"+ - ((name_entry==null)?"IdxName":"HuffName")+ - (huffman?"HuffName":"LitName")+ - (reference?"Idx":(never_index?"NeverIdx":"")); + encoding="Lit"+ + ((name_entry==null)?"HuffName":"IdxName")+ + (huffman?"HuffVal":"LitVal")+ + (reference?"Idxd":(never_index?"NeverIdx":"")); } if (name_entry!=null) diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticValueHttpField.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticValueHttpField.java index b26345626c3..7be683aa78d 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticValueHttpField.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticValueHttpField.java @@ -47,4 +47,10 @@ public class StaticValueHttpField extends HttpField { return _value; } + + @Override + public String toString() + { + return super.toString()+"(evaluated)"; + } } \ No newline at end of file diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java index 8c9a978a2ad..46a5cdc7803 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java @@ -695,6 +695,8 @@ public class HpackContextTest HpackContext ctx = new HpackContext(4096); assertEquals("content-length",ctx.get("content-length").getHttpField().getName()); assertEquals("content-length",ctx.get("Content-Length").getHttpField().getName()); + assertTrue(ctx.get("Content-Length").isStatic()); + assertTrue(ctx.get("Content-Type").isStatic()); ctx.add(new HttpField("Wibble","Wobble")); assertEquals("Wibble",ctx.get("wibble").getHttpField().getName()); 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 1a3c6ddded0..83019da8c87 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 @@ -27,6 +27,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.hpack.HpackContext; @@ -57,7 +58,7 @@ public class Http2Server { Server server = new Server(); - ServletContextHandler context = new ServletContextHandler(server, "/"); + ServletContextHandler context = new ServletContextHandler(server, "/",ServletContextHandler.SESSIONS); context.setResourceBase("/tmp"); context.addServlet(new ServletHolder(servlet), "/test/*"); context.addServlet(DefaultServlet.class, "/"); @@ -68,6 +69,8 @@ public class Http2Server HttpConfiguration http_config = new HttpConfiguration(); http_config.setSecureScheme("https"); http_config.setSecurePort(8443); + http_config.setSendXPoweredBy(true); + http_config.setSendServerVersion(true); // HTTP connector ServerConnector http = new ServerConnector(server,new HttpConnectionFactory(http_config)); @@ -118,10 +121,12 @@ public class Http2Server @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + HttpSession session = request.getSession(true); response.setHeader("custom","value"); response.setContentType("text/plain"); String content = "Hello from Jetty HTTP2\n"; content+="uri="+request.getRequestURI()+"\n"; + content+="session="+session.getId()+(session.isNew()?"(New)\n":"\n"); content+="date="+new Date()+"\n"; response.setContentLength(content.length()); response.getOutputStream().print(content);