cleaned up debug

This commit is contained in:
Greg Wilkins 2014-06-12 15:08:46 +02:00
parent 22c42151bd
commit 116d654426
5 changed files with 24 additions and 5 deletions

View File

@ -35,4 +35,10 @@ public class AuthorityHttpField extends HostPortHttpField
{ {
super(null,AUTHORITY,authority); super(null,AUTHORITY,authority);
} }
@Override
public String toString()
{
return String.format("%s(preparsed h=%s p=%d)",super.toString(),getHost(),getPort());
}
} }

View File

@ -287,10 +287,10 @@ public class HpackEncoder
if (p>=0) if (p>=0)
{ {
encoding="Literal"+ encoding="Lit"+
((name_entry==null)?"IdxName":"HuffName")+ ((name_entry==null)?"HuffName":"IdxName")+
(huffman?"HuffName":"LitName")+ (huffman?"HuffVal":"LitVal")+
(reference?"Idx":(never_index?"NeverIdx":"")); (reference?"Idxd":(never_index?"NeverIdx":""));
} }
if (name_entry!=null) if (name_entry!=null)

View File

@ -47,4 +47,10 @@ public class StaticValueHttpField extends HttpField
{ {
return _value; return _value;
} }
@Override
public String toString()
{
return super.toString()+"(evaluated)";
}
} }

View File

@ -695,6 +695,8 @@ public class HpackContextTest
HpackContext ctx = new HpackContext(4096); HpackContext ctx = new HpackContext(4096);
assertEquals("content-length",ctx.get("content-length").getHttpField().getName()); assertEquals("content-length",ctx.get("content-length").getHttpField().getName());
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")); ctx.add(new HttpField("Wibble","Wobble"));
assertEquals("Wibble",ctx.get("wibble").getHttpField().getName()); assertEquals("Wibble",ctx.get("wibble").getHttpField().getName());

View File

@ -27,6 +27,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.hpack.HpackContext; import org.eclipse.jetty.http2.hpack.HpackContext;
@ -57,7 +58,7 @@ public class Http2Server
{ {
Server server = new Server(); Server server = new Server();
ServletContextHandler context = new ServletContextHandler(server, "/"); ServletContextHandler context = new ServletContextHandler(server, "/",ServletContextHandler.SESSIONS);
context.setResourceBase("/tmp"); context.setResourceBase("/tmp");
context.addServlet(new ServletHolder(servlet), "/test/*"); context.addServlet(new ServletHolder(servlet), "/test/*");
context.addServlet(DefaultServlet.class, "/"); context.addServlet(DefaultServlet.class, "/");
@ -68,6 +69,8 @@ public class Http2Server
HttpConfiguration http_config = new HttpConfiguration(); HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https"); http_config.setSecureScheme("https");
http_config.setSecurePort(8443); http_config.setSecurePort(8443);
http_config.setSendXPoweredBy(true);
http_config.setSendServerVersion(true);
// HTTP connector // HTTP connector
ServerConnector http = new ServerConnector(server,new HttpConnectionFactory(http_config)); ServerConnector http = new ServerConnector(server,new HttpConnectionFactory(http_config));
@ -118,10 +121,12 @@ public class Http2Server
@Override @Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ {
HttpSession session = request.getSession(true);
response.setHeader("custom","value"); response.setHeader("custom","value");
response.setContentType("text/plain"); response.setContentType("text/plain");
String content = "Hello from Jetty HTTP2\n"; String content = "Hello from Jetty HTTP2\n";
content+="uri="+request.getRequestURI()+"\n"; content+="uri="+request.getRequestURI()+"\n";
content+="session="+session.getId()+(session.isNew()?"(New)\n":"\n");
content+="date="+new Date()+"\n"; content+="date="+new Date()+"\n";
response.setContentLength(content.length()); response.setContentLength(content.length());
response.getOutputStream().print(content); response.getOutputStream().print(content);