use of com.questdb.net.http.handlers.StaticContentHandler in project questdb by bluestreak01.
the class HttpServerTest method testMaxConnections.
@Test
public void testMaxConnections() throws Exception {
final ServerConfiguration configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
BootstrapEnv env = new BootstrapEnv();
env.configuration = configuration;
env.configuration.setHttpMaxConnections(1);
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
Assert.assertNotNull(clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html")));
try {
clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html"));
Assert.fail("Expected server to reject connection");
} catch (Exception ignored) {
}
} finally {
server.halt();
}
}
use of com.questdb.net.http.handlers.StaticContentHandler in project questdb by bluestreak01.
the class HttpServerTest method testNativeNotModified.
@Test
public void testNativeNotModified() throws Exception {
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
env.configuration.getSslConfig().setSecure(false);
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
assertNotModified(env.configuration, server);
}
use of com.questdb.net.http.handlers.StaticContentHandler in project questdb by bluestreak01.
the class HttpServerTest method testIdleTimeout.
@Test
public void testIdleTimeout() throws Exception {
final BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
// 500ms timeout
env.configuration.setHttpTimeout(500);
env.configuration.getSslConfig().setSecure(false);
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
Socket socket = new Socket("127.0.0.1", 9000);
OutputStream os = socket.getOutputStream();
Thread.sleep(600);
try {
os.write(request.getBytes());
for (int i = 0; i < 4096; i++) {
os.write('c');
}
os.flush();
Assert.fail("Expected exception due to connection timeout");
} catch (SocketException ignored) {
}
} finally {
server.halt();
}
}
use of com.questdb.net.http.handlers.StaticContentHandler in project questdb by bluestreak01.
the class HttpServerTest method testCompressedDownload.
@Test
public void testCompressedDownload() throws Exception {
final ServerConfiguration configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
configuration.getSslConfig().setSecure(true);
configuration.getSslConfig().setKeyStore(new FileInputStream(resourceFile("/keystore/singlekey.ks")), "changeit");
BootstrapEnv env = new BootstrapEnv();
env.configuration = configuration;
env.matcher = new SimpleUrlMatcher() {
{
setDefaultHandler(new StaticContentHandler(env));
}
};
HttpServer server = new HttpServer(env);
server.start();
try {
HttpTestUtils.download(clientBuilder(true), "https://localhost:9000/upload.html", new File(temp.getRoot(), "upload.html"));
} finally {
server.halt();
}
}
use of com.questdb.net.http.handlers.StaticContentHandler in project questdb by bluestreak01.
the class HttpServerTest method testRangesNative.
@Test
// fix is in server, which would allow limited number of this iterations after which connection is closed.
@Ignore
public void testRangesNative() throws Exception {
BootstrapEnv env = new BootstrapEnv();
env.configuration = new ServerConfiguration(new File(HttpServerTest.class.getResource("/site").getPath(), "conf/questdb.conf")) {
@Override
public File getHttpPublic() {
return temp.getRoot();
}
};
env.configuration.setHttpThreads(1);
env.configuration.setHttpSoRetries(10);
env.configuration.getSslConfig().setSecure(false);
env.matcher = new SimpleUrlMatcher() {
{
put("/upload", new UploadHandler(env.configuration.getHttpPublic()));
setDefaultHandler(new StaticContentHandler(env));
}
};
assertRanges(new HttpServer(env));
}
Aggregations