398467 Servlet 3.1 Non Blocking IO
Removed double dispatch due to HttpPArser content handler returning true for deferred dispatch.
This commit is contained in:
parent
c53efbaff4
commit
d8f2350f50
|
@ -1151,6 +1151,9 @@ public class HttpParser
|
|||
break;
|
||||
|
||||
case END:
|
||||
// eat white space
|
||||
while (buffer.remaining()>0 && buffer.get(buffer.position())<=HttpTokens.SPACE)
|
||||
buffer.get();
|
||||
return false;
|
||||
|
||||
case CLOSED:
|
||||
|
|
|
@ -555,8 +555,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
|||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
// Either handle now or wait for first content/message complete
|
||||
return _expect100Continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -567,7 +566,8 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
|||
@SuppressWarnings("unchecked")
|
||||
HttpInput<T> input = (HttpInput<T>)_request.getHttpInput();
|
||||
input.content(item);
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -428,20 +428,20 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
that uses the calling thread to block on a readable callback and
|
||||
then to do the parsing before before attempting the read.
|
||||
*/
|
||||
while (true)
|
||||
while (!_parser.isComplete())
|
||||
{
|
||||
// Can the parser progress (even with an empty buffer)
|
||||
boolean event=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer);
|
||||
|
||||
boolean event=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer);
|
||||
|
||||
// If there is more content to parse, loop so we can queue all content from this buffer now without the
|
||||
// need to call blockForContent again
|
||||
while (event && BufferUtil.hasContent(_requestBuffer) && _parser.inContentState())
|
||||
_parser.parseNext(_requestBuffer);
|
||||
while (!event && BufferUtil.hasContent(_requestBuffer) && _parser.inContentState())
|
||||
event=_parser.parseNext(_requestBuffer);
|
||||
|
||||
// If we have an event, return
|
||||
if (event)
|
||||
// If we have content, return
|
||||
if (_parser.isComplete() || available()>0)
|
||||
return;
|
||||
|
||||
|
||||
// Do we have content ready to parse?
|
||||
if (BufferUtil.isEmpty(_requestBuffer))
|
||||
{
|
||||
|
|
|
@ -466,10 +466,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
|
||||
// Pick fragment points at random
|
||||
for (int j = 0; j < points.length; ++j)
|
||||
{
|
||||
points[j] = random.nextInt(bytes.length);
|
||||
}
|
||||
// System.err.println("points "+points[0]+" "+points[1]);
|
||||
|
||||
// Sort the list
|
||||
Arrays.sort(points);
|
||||
|
@ -1138,15 +1135,20 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
InputStream in = request.getInputStream();
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
|
||||
// should always be some input available, because of deferred dispatch.
|
||||
// this should initially be 0 bytes available.
|
||||
int avail = in.available();
|
||||
out.println(avail);
|
||||
|
||||
// block for the first character
|
||||
String buf = "";
|
||||
buf += (char)in.read();
|
||||
|
||||
// read remaining available bytes
|
||||
avail = in.available();
|
||||
out.println(avail);
|
||||
for (int i = 0; i < avail; i++)
|
||||
buf += (char)in.read();
|
||||
|
||||
|
||||
avail = in.available();
|
||||
out.println(avail);
|
||||
|
||||
|
@ -1238,10 +1240,11 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
// skip header
|
||||
while (reader.readLine().length() > 0) ;
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.equalTo(0));
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.equalTo(9));
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.equalTo(0));
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.greaterThan(0));
|
||||
assertEquals(0, Integer.parseInt(reader.readLine()));
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.greaterThan(0));
|
||||
assertEquals(0, Integer.parseInt(reader.readLine()));
|
||||
assertThat(Integer.parseInt(reader.readLine()), Matchers.equalTo(0));
|
||||
assertEquals("1234567890abcdefghijklmnopqrst", reader.readLine());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,4 @@ public class SelectChannelServerTest extends HttpServerTestBase
|
|||
{
|
||||
startServer(new ServerConnector(_server));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testBlockingWhileWritingResponseContent() throws Exception
|
||||
{
|
||||
super.testBlockingWhileWritingResponseContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -270,6 +270,7 @@ public class SSLEngineTest
|
|||
{
|
||||
((HttpsURLConnection)conn).setHostnameVerifier(new HostnameVerifier()
|
||||
{
|
||||
@Override
|
||||
public boolean verify(String urlHostName, SSLSession session)
|
||||
{
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue