diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index 4c0ffd8daae..994646301b1 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -309,6 +309,8 @@ public abstract class HttpChannel /* ------------------------------------------------------------ */ protected void handleRequest() throws IOException { + System.err.println("handleRequest"); + boolean error = false; String threadName=null; @@ -506,6 +508,7 @@ public abstract class HttpChannel { synchronized (_inputQ.lock()) { + System.err.println("read "+len+" "+_inputQ); ByteBuffer content=null; while(content==null) { @@ -525,6 +528,8 @@ public abstract class HttpChannel blockForContent(); } } + + System.err.println("reading "+len+" "+BufferUtil.toDetailString(content)); int l=Math.min(len,content.remaining()); content.get(b,off,l); @@ -598,58 +603,60 @@ public abstract class HttpChannel @Override public boolean parsedHeader(HttpHeader header, String name, String value) throws IOException { - switch (header) + if (header!=null) { - case HOST: - // TODO check if host matched a host in the URI. - _host = true; - break; + switch (header) + { + case HOST: + // TODO check if host matched a host in the URI. + _host = true; + break; - case EXPECT: - HttpHeaderValue expect = HttpHeaderValue.CACHE.get(value); - switch(expect==null?HttpHeaderValue.UNKNOWN:expect) - { - case CONTINUE: - _expect100Continue=true; - break; + case EXPECT: + HttpHeaderValue expect = HttpHeaderValue.CACHE.get(value); + switch(expect==null?HttpHeaderValue.UNKNOWN:expect) + { + case CONTINUE: + _expect100Continue=true; + break; - case PROCESSING: - _expect102Processing=true; - break; + case PROCESSING: + _expect102Processing=true; + break; - default: - String[] values = value.toString().split(","); - for (int i=0;values!=null && i block=new FutureCallback<>(); - getEndPoint().readable(null,block); - block.get(); + System.err.println("blockForContent: "+BufferUtil.toDetailString(_requestBuffer)); + + // Do we have content ready to parse? + if (BufferUtil.isEmpty(_requestBuffer)) + { + // Wait until we can read + FutureCallback block=new FutureCallback<>(); + getEndPoint().readable(null,block); + block.get(); - // We will need a buffer to read into - if (_requestBuffer==null) - _requestBuffer=_bufferPool.acquire(_connector.getRequestBufferSize(),false); + // We will need a buffer to read into + if (_requestBuffer==null) + _requestBuffer=_bufferPool.acquire(_connector.getRequestBufferSize(),false); - int filled=getEndPoint().fill(_requestBuffer); - LOG.debug("{} filled {}",this,filled); + int filled=getEndPoint().fill(_requestBuffer); + LOG.debug("{} filled {}",this,filled); + } // If we parse to an event, return while (BufferUtil.hasContent(_requestBuffer) && _parser.inContentState()) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java index 0fad74a9f72..db00d8efb4a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java @@ -37,6 +37,8 @@ public class HttpInput extends ServletInputStream public int read() throws IOException { int len=_channel.read(_byte,0,1); + if (len>0) + System.err.println("READ "+_byte[0]); return len<0?len:_byte[0]; } @@ -47,7 +49,7 @@ public class HttpInput extends ServletInputStream @Override public int read(byte[] b, int off, int len) throws IOException { - return _channel.read(_byte,0,1); + return _channel.read(b,off,len); } /* ------------------------------------------------------------ */