333415 improved available handling for sockets

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2639 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-01-10 15:12:40 +00:00
parent 8e41e025b9
commit 7ce3d368cf
2 changed files with 19 additions and 3 deletions

View File

@ -23,6 +23,8 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
import org.eclipse.jetty.io.bio.StreamEndPoint;
import org.eclipse.jetty.io.nio.ChannelEndPoint;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
@ -1158,9 +1160,16 @@ public class HttpParser implements Parser
{
if (_contentView!=null && _contentView.length()>0)
return _contentView.length();
if (!_endp.isBlocking())
parseNext();
if (_endp.isBlocking())
{
if (_state>0 && _endp instanceof StreamEndPoint)
return ((StreamEndPoint)_endp).getInputStream().available()>0?1:0;
return 0;
}
parseNext();
return _contentView==null?0:_contentView.length();
}

View File

@ -908,7 +908,14 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
if (avail==0)
{
// handle blocking connectors
// handle blocking channel connectors
buf+=(char)in.read();
avail=in.available();
out.println(avail+1);
}
else if (avail==1)
{
// handle blocking socket connectors
buf+=(char)in.read();
avail=in.available();
out.println(avail+1);