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);
}
@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)
{
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)

View File

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

View File

@ -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());

View File

@ -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);