use of org.eclipse.jetty.server.HttpConnectionFactory in project jetty.project by eclipse.
the class DataConstraintsTest method startServer.
@Before
public void startServer() {
_server = new Server();
HttpConnectionFactory http = new HttpConnectionFactory();
http.getHttpConfiguration().setSecurePort(9999);
http.getHttpConfiguration().setSecureScheme("BWTP");
_connector = new LocalConnector(_server, http);
_connector.setIdleTimeout(300000);
HttpConnectionFactory https = new HttpConnectionFactory();
https.getHttpConfiguration().addCustomizer(new HttpConfiguration.Customizer() {
@Override
public void customize(Connector connector, HttpConfiguration channelConfig, Request request) {
request.setScheme(HttpScheme.HTTPS.asString());
request.setSecure(true);
}
});
_connectorS = new LocalConnector(_server, https);
_server.setConnectors(new Connector[] { _connector, _connectorS });
ContextHandler _context = new ContextHandler();
_session = new SessionHandler();
_context.setContextPath("/ctx");
_server.setHandler(_context);
_context.setHandler(_session);
_security = new ConstraintSecurityHandler();
_session.setHandler(_security);
_security.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
baseRequest.setHandled(true);
response.sendError(404);
}
});
}
use of org.eclipse.jetty.server.HttpConnectionFactory in project jetty.project by eclipse.
the class AsyncMiddleManServletTest method startProxy.
private void startProxy(AsyncMiddleManServlet proxyServlet, Map<String, String> initParams) throws Exception {
QueuedThreadPool proxyPool = new QueuedThreadPool();
proxyPool.setName("proxy");
proxy = new Server(proxyPool);
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
String value = initParams.get("outputBufferSize");
if (value != null)
configuration.setOutputBufferSize(Integer.valueOf(value));
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyServletHolder.setInitParameters(initParams);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
stackless = new StacklessLogging(proxyServlet._log);
}
use of org.eclipse.jetty.server.HttpConnectionFactory in project jetty.project by eclipse.
the class ComplianceViolations2616Test method startServer.
@BeforeClass
public static void startServer() throws Exception {
server = new Server();
HttpConfiguration config = new HttpConfiguration();
config.setSendServerVersion(false);
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config, HttpCompliance.RFC2616);
httpConnectionFactory.setRecordHttpComplianceViolations(true);
connector = new LocalConnector(server, null, null, null, -1, httpConnectionFactory);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
context.setWelcomeFiles(new String[] { "index.html", "index.jsp", "index.htm" });
context.addServlet(DumpRequestHeadersServlet.class, "/dump/*");
context.addFilter(ReportViolationsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
server.setHandler(context);
server.addConnector(connector);
server.start();
}
use of org.eclipse.jetty.server.HttpConnectionFactory in project jetty.project by eclipse.
the class ProxyServletLoadTest method startProxy.
private void startProxy() throws Exception {
QueuedThreadPool proxyPool = new QueuedThreadPool();
proxyPool.setName("proxy");
proxy = new Server(proxyPool);
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
use of org.eclipse.jetty.server.HttpConnectionFactory in project jetty.project by eclipse.
the class ReverseProxyTest method startProxy.
private void startProxy(Map<String, String> params) throws Exception {
proxy = new Server();
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(new AsyncMiddleManServlet() {
@Override
protected String rewriteTarget(HttpServletRequest clientRequest) {
StringBuilder builder = new StringBuilder();
builder.append(clientRequest.getScheme()).append("://127.0.0.1:");
builder.append(serverConnector.getLocalPort());
builder.append(clientRequest.getRequestURI());
String query = clientRequest.getQueryString();
if (query != null)
builder.append("?").append(query);
return builder.toString();
}
});
if (params != null)
proxyServletHolder.setInitParameters(params);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
Aggregations