306376 extra tests
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1398 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
6ba2789cab
commit
40ee939b4e
|
@ -26,6 +26,7 @@ import org.eclipse.jetty.http.HttpHeaders;
|
||||||
import org.eclipse.jetty.http.HttpMethods;
|
import org.eclipse.jetty.http.HttpMethods;
|
||||||
import org.eclipse.jetty.http.HttpParser;
|
import org.eclipse.jetty.http.HttpParser;
|
||||||
import org.eclipse.jetty.http.HttpSchemes;
|
import org.eclipse.jetty.http.HttpSchemes;
|
||||||
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.http.HttpVersions;
|
import org.eclipse.jetty.http.HttpVersions;
|
||||||
import org.eclipse.jetty.http.ssl.SslSelectChannelEndPoint;
|
import org.eclipse.jetty.http.ssl.SslSelectChannelEndPoint;
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
|
@ -49,6 +50,7 @@ public class HttpConnection implements Connection
|
||||||
private HttpGenerator _generator;
|
private HttpGenerator _generator;
|
||||||
private HttpParser _parser;
|
private HttpParser _parser;
|
||||||
private boolean _http11 = true;
|
private boolean _http11 = true;
|
||||||
|
private int _status;
|
||||||
private Buffer _connectionHeader;
|
private Buffer _connectionHeader;
|
||||||
private Buffer _requestContentChunk;
|
private Buffer _requestContentChunk;
|
||||||
private boolean _requestComplete;
|
private boolean _requestComplete;
|
||||||
|
@ -330,30 +332,33 @@ public class HttpConnection implements Connection
|
||||||
no_progress = 0;
|
no_progress = 0;
|
||||||
if (_exchange != null)
|
if (_exchange != null)
|
||||||
{
|
{
|
||||||
_exchange.disassociate();
|
if (_status!=HttpStatus.SWITCHING_PROTOCOLS_101 || !_exchange.onSwitchProtocol(_endp))
|
||||||
_exchange = null;
|
{
|
||||||
|
_exchange.disassociate();
|
||||||
|
_exchange = null;
|
||||||
|
|
||||||
if (_pipeline == null)
|
if (_pipeline == null)
|
||||||
{
|
|
||||||
if (!isReserved())
|
|
||||||
_destination.returnConnection(this, close);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (close)
|
|
||||||
{
|
{
|
||||||
if (!isReserved())
|
if (!isReserved())
|
||||||
_destination.returnConnection(this,close);
|
_destination.returnConnection(this, close);
|
||||||
|
|
||||||
HttpExchange exchange = _pipeline;
|
|
||||||
_pipeline = null;
|
|
||||||
_destination.send(exchange);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HttpExchange exchange = _pipeline;
|
if (close)
|
||||||
_pipeline = null;
|
{
|
||||||
send(exchange);
|
if (!isReserved())
|
||||||
|
_destination.returnConnection(this,close);
|
||||||
|
|
||||||
|
HttpExchange exchange = _pipeline;
|
||||||
|
_pipeline = null;
|
||||||
|
_destination.send(exchange);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HttpExchange exchange = _pipeline;
|
||||||
|
_pipeline = null;
|
||||||
|
send(exchange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,6 +403,7 @@ public class HttpConnection implements Connection
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
|
_status=0;
|
||||||
if (_exchange.getStatus() != HttpExchange.STATUS_WAITING_FOR_COMMIT)
|
if (_exchange.getStatus() != HttpExchange.STATUS_WAITING_FOR_COMMIT)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
@ -500,6 +506,7 @@ public class HttpConnection implements Connection
|
||||||
if (exchange!=null)
|
if (exchange!=null)
|
||||||
{
|
{
|
||||||
_http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
|
_http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
|
||||||
|
_status=status;
|
||||||
exchange.getEventListener().onResponseStatus(version,status,reason);
|
exchange.getEventListener().onResponseStatus(version,status,reason);
|
||||||
exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS);
|
exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.http.HttpSchemes;
|
||||||
import org.eclipse.jetty.http.HttpURI;
|
import org.eclipse.jetty.http.HttpURI;
|
||||||
import org.eclipse.jetty.http.HttpVersions;
|
import org.eclipse.jetty.http.HttpVersions;
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
@ -656,6 +657,13 @@ public class HttpExchange
|
||||||
return getClass().getSimpleName() + "@" + hashCode() + "=" + _method + "//" + _address + _uri + "#" + getStatus();
|
return getClass().getSimpleName() + "@" + hashCode() + "=" + _method + "//" + _address + _uri + "#" + getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected boolean onSwitchProtocol(EndPoint enpd) throws IOException
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback called when the request headers have been sent to the server.
|
* Callback called when the request headers have been sent to the server.
|
||||||
* This implementation does nothing.
|
* This implementation does nothing.
|
||||||
|
|
|
@ -37,6 +37,7 @@ import javax.net.ssl.SSLSession;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
|
import org.eclipse.jetty.util.IO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpServer Tester.
|
* HttpServer Tester.
|
||||||
|
@ -75,23 +77,25 @@ public class SSLEngineTest extends TestCase
|
||||||
private static final String RESPONSE1="HTTP/1.1 200 OK\n"+"Connection: close\n"+"Server: Jetty("+JETTY_VERSION+")\n"+'\n'+HELLO_WORLD;
|
private static final String RESPONSE1="HTTP/1.1 200 OK\n"+"Connection: close\n"+"Server: Jetty("+JETTY_VERSION+")\n"+'\n'+HELLO_WORLD;
|
||||||
|
|
||||||
private static final TrustManager[] s_dummyTrustManagers=new TrustManager[]
|
private static final TrustManager[] s_dummyTrustManagers=new TrustManager[]
|
||||||
{ new X509TrustManager()
|
{
|
||||||
{
|
new X509TrustManager()
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
{
|
||||||
return null;
|
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
|
|
||||||
{
|
|
||||||
}
|
|
||||||
} };
|
|
||||||
|
|
||||||
Server server;
|
Server server;
|
||||||
SslSelectChannelConnector connector;
|
SslSelectChannelConnector connector;
|
||||||
|
@ -113,6 +117,8 @@ public class SSLEngineTest extends TestCase
|
||||||
connector.setKeystore(keystore);
|
connector.setKeystore(keystore);
|
||||||
connector.setPassword("storepwd");
|
connector.setPassword("storepwd");
|
||||||
connector.setKeyPassword("keypwd");
|
connector.setKeyPassword("keypwd");
|
||||||
|
connector.setRequestBufferSize(512);
|
||||||
|
connector.setRequestHeaderSize(512);
|
||||||
|
|
||||||
server.setConnectors(new Connector[]
|
server.setConnectors(new Connector[]
|
||||||
{ connector });
|
{ connector });
|
||||||
|
@ -134,16 +140,45 @@ public class SSLEngineTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Feed the server the entire request at once.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testBigResponse() throws Exception
|
||||||
|
{
|
||||||
|
SSLContext ctx=SSLContext.getInstance("SSLv3");
|
||||||
|
ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
|
||||||
|
|
||||||
|
int port=connector.getLocalPort();
|
||||||
|
|
||||||
|
Socket client=ctx.getSocketFactory().createSocket("localhost",port);
|
||||||
|
OutputStream os=client.getOutputStream();
|
||||||
|
|
||||||
|
String request =
|
||||||
|
"GET /?dump=102400 HTTP/1.1\r\n"+
|
||||||
|
"Host: localhost:8080\r\n"+
|
||||||
|
"Connection: close\r\n"+
|
||||||
|
"\r\n";
|
||||||
|
|
||||||
|
os.write(request.getBytes());
|
||||||
|
os.flush();
|
||||||
|
|
||||||
|
String response = IO.toString(client.getInputStream());
|
||||||
|
|
||||||
|
assertTrue(response.length()>102400);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed the server the entire request at once.
|
* Feed the server the entire request at once.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void /*test*/RequestJettyHttps() throws Exception
|
public void testRequestJettyHttps() throws Exception
|
||||||
{
|
{
|
||||||
final int loops=100;
|
final int loops=10;
|
||||||
final int numConns=100;
|
final int numConns=10;
|
||||||
|
|
||||||
Socket[] client=new Socket[numConns];
|
Socket[] client=new Socket[numConns];
|
||||||
|
|
||||||
|
@ -259,15 +294,21 @@ public class SSLEngineTest extends TestCase
|
||||||
{
|
{
|
||||||
// System.err.println("HANDLE "+request.getRequestURI());
|
// System.err.println("HANDLE "+request.getRequestURI());
|
||||||
String ssl_id = (String)request.getAttribute("javax.servlet.request.ssl_session_id");
|
String ssl_id = (String)request.getAttribute("javax.servlet.request.ssl_session_id");
|
||||||
//assertNotNull(ssl_id);
|
assertNotNull(ssl_id);
|
||||||
PrintWriter out=response.getWriter();
|
|
||||||
|
|
||||||
try
|
if (request.getParameter("dump")!=null)
|
||||||
{
|
{
|
||||||
|
ServletOutputStream out=response.getOutputStream();
|
||||||
|
byte[] buf = new byte[Integer.valueOf(request.getParameter("dump"))];
|
||||||
|
for (int i=0;i<buf.length;i++)
|
||||||
|
buf[i]=(byte)('0'+(i%10));
|
||||||
|
out.write(buf);
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintWriter out=response.getWriter();
|
||||||
out.print(HELLO_WORLD);
|
out.print(HELLO_WORLD);
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,6 +394,7 @@ public class SSLEngineTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class StreamHandler extends AbstractHandler
|
public static class StreamHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
public int bytes=0;
|
public int bytes=0;
|
||||||
|
|
Loading…
Reference in New Issue