324260 jetty-6 continuations support complete calls
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2236 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
bc1fcba91d
commit
c0759a44f1
|
@ -20,6 +20,7 @@ jetty-7.2-SNAPSHOT
|
|||
+ 323464 IPv6 localhost with no Host header
|
||||
+ 324110 Merge async dispatch parameters
|
||||
+ 324158 Durable download or Orbit jars
|
||||
+ 324260 Jetty-6 continuations handle complete calls
|
||||
+ JETTY-912 added per exchange timeout api
|
||||
+ JETTY-1245 Do not use direct buffers with NIO SSL
|
||||
+ JETTY-1249 Apply max idle time to all connectors
|
||||
|
|
|
@ -73,7 +73,6 @@ public class ContinuationFilter implements Filter
|
|||
{
|
||||
if (_filtered)
|
||||
{
|
||||
|
||||
Continuation c = (Continuation) request.getAttribute(Continuation.ATTRIBUTE);
|
||||
FilteredContinuation fc;
|
||||
if (_faux && (c==null || !(c instanceof FauxContinuation)))
|
||||
|
|
|
@ -220,11 +220,9 @@ public class Jetty6Continuation implements ContinuationFilter.FilteredContinuati
|
|||
for (ContinuationListener l: _listeners)
|
||||
l.onTimeout(this);
|
||||
}
|
||||
|
||||
return !_completed;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !_completed;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -52,5 +52,12 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.eclipse.jetty.continuation;
|
||||
|
||||
import org.eclipse.jetty.servlets.ProxyServlet;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.nio.SelectChannelConnector;
|
||||
import org.mortbay.jetty.servlet.Context;
|
||||
import org.mortbay.jetty.servlet.FilterHolder;
|
||||
import org.mortbay.jetty.servlet.ServletHandler;
|
||||
import org.mortbay.jetty.servlet.ServletHolder;
|
||||
|
||||
public class TestProxyServer
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
|
||||
server.setConnectors(new Connector[]{ selectChannelConnector });
|
||||
selectChannelConnector.setPort(8080);
|
||||
|
||||
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
|
||||
server.setHandler(servletContext);
|
||||
ServletHandler servletHandler=servletContext.getServletHandler();
|
||||
|
||||
|
||||
ServletHolder proxy=new ServletHolder(ProxyServlet.Transparent.class);
|
||||
servletHandler.addServletWithMapping(proxy,"/ws/*");
|
||||
proxy.setInitParameter("ProxyTo","http://www.webtide.com");
|
||||
proxy.setInitParameter("Prefix","/ws");
|
||||
|
||||
FilterHolder filter=servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
|
||||
filter.setInitParameter("debug","true");
|
||||
|
||||
server.start();
|
||||
server.join();
|
||||
}
|
||||
}
|
|
@ -80,18 +80,22 @@ public abstract class ContinuationBase extends TestCase
|
|||
|
||||
protected void doSuspendWaitComplete() throws Exception
|
||||
{
|
||||
String response=process("suspend=200&complete=10",null);
|
||||
String response=process("suspend=200&complete=50",null);
|
||||
assertContains("COMPLETED",response);
|
||||
assertContains("history: initial",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
assertNotContains("history: !initial",response);
|
||||
}
|
||||
|
||||
protected void doSuspendComplete() throws Exception
|
||||
{
|
||||
String response=process("suspend=200&complete=0",null);
|
||||
assertContains("COMPLETED",response);
|
||||
assertContains("history: initial",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
assertNotContains("history: !initial",response);
|
||||
}
|
||||
|
||||
protected void doSuspendWaitResumeSuspendWaitResume() throws Exception
|
||||
|
@ -289,6 +293,7 @@ public abstract class ContinuationBase extends TestCase
|
|||
|
||||
if (continuation.isInitial())
|
||||
{
|
||||
((HttpServletResponse)response).addHeader("history","initial");
|
||||
if (read_before>0)
|
||||
{
|
||||
byte[] buf=new byte[read_before];
|
||||
|
@ -384,85 +389,89 @@ public abstract class ContinuationBase extends TestCase
|
|||
response.getOutputStream().println("NORMAL\n");
|
||||
}
|
||||
}
|
||||
else if (suspend2_for>=0 && request.getAttribute("2nd")==null)
|
||||
else
|
||||
{
|
||||
request.setAttribute("2nd","cycle");
|
||||
|
||||
if (suspend2_for>0)
|
||||
continuation.setTimeout(suspend2_for);
|
||||
// continuation.addContinuationListener(__listener);
|
||||
((HttpServletResponse)response).addHeader("history","suspend");
|
||||
continuation.suspend(response);
|
||||
|
||||
if (complete2_after>0)
|
||||
((HttpServletResponse)response).addHeader("history","!initial");
|
||||
if (suspend2_for>=0 && request.getAttribute("2nd")==null)
|
||||
{
|
||||
TimerTask complete = new TimerTask()
|
||||
request.setAttribute("2nd","cycle");
|
||||
|
||||
if (suspend2_for>0)
|
||||
continuation.setTimeout(suspend2_for);
|
||||
// continuation.addContinuationListener(__listener);
|
||||
((HttpServletResponse)response).addHeader("history","suspend");
|
||||
continuation.suspend(response);
|
||||
|
||||
if (complete2_after>0)
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
TimerTask complete = new TimerTask()
|
||||
{
|
||||
try
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(complete,complete2_after);
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(complete,complete2_after);
|
||||
}
|
||||
else if (complete2_after==0)
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
else if (resume2_after>0)
|
||||
{
|
||||
TimerTask resume = new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
((HttpServletResponse)response).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(resume,resume2_after);
|
||||
}
|
||||
}
|
||||
else if (resume2_after==0)
|
||||
{
|
||||
((HttpServletResponse)response).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
if (undispatch)
|
||||
continuation.undispatch();
|
||||
return;
|
||||
}
|
||||
else if (complete2_after==0)
|
||||
else if (continuation.isExpired())
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
response.getOutputStream().println("TIMEOUT\n");
|
||||
}
|
||||
else if (resume2_after>0)
|
||||
else if (continuation.isResumed())
|
||||
{
|
||||
TimerTask resume = new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
((HttpServletResponse)response).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(resume,resume2_after);
|
||||
}
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("RESUMED\n");
|
||||
}
|
||||
else if (resume2_after==0)
|
||||
else
|
||||
{
|
||||
((HttpServletResponse)response).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("unknown???\n");
|
||||
}
|
||||
if (undispatch)
|
||||
continuation.undispatch();
|
||||
return;
|
||||
}
|
||||
else if (continuation.isExpired())
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("TIMEOUT\n");
|
||||
}
|
||||
else if (continuation.isResumed())
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("RESUMED\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("unknown???\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue