use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class AbstractHttpClientServerTest method start.
public void start(Handler handler) throws Exception {
server = new Server();
ServerFCGIConnectionFactory fcgiConnectionFactory = new ServerFCGIConnectionFactory(new HttpConfiguration());
serverBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
connector = new ServerConnector(server, null, null, serverBufferPool, 1, Math.max(1, Runtime.getRuntime().availableProcessors() / 2), fcgiConnectionFactory);
// connector.setPort(9000);
server.addConnector(connector);
server.setHandler(handler);
server.start();
QueuedThreadPool executor = new QueuedThreadPool();
executor.setName(executor.getName() + "-client");
client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "") {
@Override
public HttpDestination newHttpDestination(Origin origin) {
return new HttpDestinationOverFCGI(client, origin) {
@Override
protected DuplexConnectionPool newConnectionPool(HttpClient client) {
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this) {
@Override
protected void leaked(LeakDetector.LeakInfo leakInfo) {
connectionLeaks.incrementAndGet();
}
};
}
};
}
}, null);
client.setExecutor(executor);
clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
client.setByteBufferPool(clientBufferPool);
client.start();
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class FastCGIProxyServletTest method prepare.
public void prepare(HttpServlet servlet) throws Exception {
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
server = new Server(serverThreads);
httpConnector = new ServerConnector(server);
server.addConnector(httpConnector);
fcgiConnector = new ServerConnector(server, new ServerFCGIConnectionFactory(new HttpConfiguration(), sendStatus200));
server.addConnector(fcgiConnector);
final String contextPath = "/";
context = new ServletContextHandler(server, contextPath);
final String servletPath = "/script";
FastCGIProxyServlet fcgiServlet = new FastCGIProxyServlet() {
@Override
protected String rewriteTarget(HttpServletRequest request) {
return "http://localhost:" + fcgiConnector.getLocalPort() + servletPath + request.getServletPath();
}
};
ServletHolder fcgiServletHolder = new ServletHolder(fcgiServlet);
fcgiServletHolder.setName("fcgi");
fcgiServletHolder.setInitParameter(FastCGIProxyServlet.SCRIPT_ROOT_INIT_PARAM, "/scriptRoot");
fcgiServletHolder.setInitParameter("proxyTo", "http://localhost");
fcgiServletHolder.setInitParameter(FastCGIProxyServlet.SCRIPT_PATTERN_INIT_PARAM, "(.+?\\.php)");
context.addServlet(fcgiServletHolder, "*.php");
context.addServlet(new ServletHolder(servlet), servletPath + "/*");
QueuedThreadPool clientThreads = new QueuedThreadPool();
clientThreads.setName("client");
client = new HttpClient();
client.setExecutor(clientThreads);
server.addBean(client);
server.start();
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class AbstractTest method start.
protected void start(Handler handler) throws Exception {
prepareServer(new HTTP2ServerConnectionFactory(new HttpConfiguration()));
server.setHandler(handler);
server.start();
prepareClient();
client.start();
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class SecuredRedirectHandler method handle.
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
HttpChannel channel = baseRequest.getHttpChannel();
if (baseRequest.isSecure() || (channel == null)) {
// nothing to do
return;
}
HttpConfiguration httpConfig = channel.getHttpConfiguration();
if (httpConfig == null) {
// no config, show error
response.sendError(HttpStatus.FORBIDDEN_403, "No http configuration available");
return;
}
if (httpConfig.getSecurePort() > 0) {
String scheme = httpConfig.getSecureScheme();
int port = httpConfig.getSecurePort();
String url = URIUtil.newURI(scheme, baseRequest.getServerName(), port, baseRequest.getRequestURI(), baseRequest.getQueryString());
response.setContentLength(0);
response.sendRedirect(url);
} else {
response.sendError(HttpStatus.FORBIDDEN_403, "Not Secure");
}
baseRequest.setHandled(true);
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class AsyncServletIOTest method setUp.
@Before
public void setUp() throws Exception {
HttpConfiguration http_config = new HttpConfiguration();
http_config.setOutputBufferSize(4096);
_connector = new ServerConnector(_server, new HttpConnectionFactory(http_config));
_server.setConnectors(new Connector[] { _connector });
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/ctx");
context.addEventListener(new DebugListener());
_server.setHandler(context);
_servletHandler = context.getServletHandler();
ServletHolder holder = new ServletHolder(_servlet0);
holder.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder, "/path/*");
ServletHolder holder2 = new ServletHolder(_servlet2);
holder2.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder2, "/path2/*");
ServletHolder holder3 = new ServletHolder(_servlet3);
holder3.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder3, "/path3/*");
ServletHolder holder4 = new ServletHolder(_servlet4);
holder4.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder4, "/path4/*");
_server.start();
_port = _connector.getLocalPort();
_owp.set(0);
_oda.set(0);
_read.set(0);
}
Aggregations