List of usage examples for org.apache.http.protocol ImmutableHttpProcessor ImmutableHttpProcessor
@Deprecated
public ImmutableHttpProcessor(HttpRequestInterceptorList httpRequestInterceptorList,
HttpResponseInterceptorList httpResponseInterceptorList)
From source file:brooklyn.test.TestHttpServer.java
public TestHttpServer start() { checkNotStarted();//ww w . java 2 s . c o m HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors); int port = Networking.nextAvailablePort(basePort); ServerBootstrap bootstrap = ServerBootstrap.bootstrap().setListenerPort(port) .setLocalAddress(getLocalAddress()).setHttpProcessor(httpProcessor); for (HandlerTuple tuple : handlers) { bootstrap.registerHandler(tuple.path, tuple.handler); } server = bootstrap.create(); try { server.start(); } catch (IOException e) { throw Exceptions.propagate(e); } return this; }
From source file:com.jrodeo.remote.TestHttpCore.java
public TestHttpCore() { super();// ww w. j a va 2 s. c o m this.params = new SyncBasicHttpParams(); this.params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); this.params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); this.params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false); this.params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); this.params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 15000); this.httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] { new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent() }, null); this.httpexecutor = new HttpRequestExecutor(); this.connStrategy = new DefaultConnectionReuseStrategy(); this.pool = new BasicConnPool(this.params); }
From source file:com.eislab.af.translator.spokes.HttpServer_spoke.java
public HttpServer_spoke(String ipaddress, String path) throws IOException, InterruptedException { address = ipaddress;/* w w w. j a v a2 s . co m*/ // HTTP parameters for the server HttpParams params = new SyncBasicHttpParams(); params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, SOCKET_TIMEOUT) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, SOCKET_BUFFER_SIZE) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, SERVER_NAME); // Create HTTP protocol processing chain // Use standard server-side protocol interceptors HttpRequestInterceptor[] requestInterceptors = new HttpRequestInterceptor[] { new RequestAcceptEncoding() }; HttpResponseInterceptor[] responseInterceptors = new HttpResponseInterceptor[] { new ResponseAllowCORS(), new ResponseContentEncoding(), new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl() }; HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors); // Create request handler registry HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry(); // register the handler that will reply to the proxy requests registry.register(path, new RequestHandler("", true)); // Create server-side HTTP protocol handler HttpAsyncService protocolHandler = new HttpAsyncService(httpProcessor, new DefaultConnectionReuseStrategy(), registry, params); // Create HTTP connection factory NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory = new DefaultNHttpServerConnectionFactory( params); // Create server-side I/O event dispatch final IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(protocolHandler, connFactory); try { // Create server-side I/O reactor ioReactor = new DefaultListeningIOReactor(); // Listen of the given port InetSocketAddress socketAddress = new InetSocketAddress(ipaddress, 0); ListenerEndpoint endpoint1 = ioReactor.listen(socketAddress); // create the listener thread Thread listener = new Thread("Http listener") { @Override public void run() { try { ioReactor.execute(ioEventDispatch); } catch (IOException e) { // LOGGER.severe("I/O Exception: " + e.getMessage()); } } }; listener.setDaemon(false); listener.start(); endpoint1.waitFor(); if (address.contains(":")) { if (!address.startsWith("[")) { address = "[" + address + "]"; } } address = address + ":" + Integer.toString(((InetSocketAddress) endpoint1.getAddress()).getPort()) + "/"; System.out.println(address); } catch (IOException e) { // LOGGER.severe("I/O error: " + e.getMessage()); } }
From source file:org.apache.camel.component.http4.HttpProxyServerTest.java
@Override @Before/*w ww .jav a 2 s.c om*/ public void setUp() throws Exception { super.setUp(); List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>(); requestInterceptors.add(new RequestProxyBasicAuth()); List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>(); responseInterceptors.add(new ResponseContent()); responseInterceptors.add(new ResponseProxyBasicUnauthorized()); ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors); proxy = new LocalTestServer(httpproc, null); proxy.start(); }
From source file:org.apache.http.impl.client.AbstractHttpClient.java
private synchronized HttpProcessor getProtocolProcessor() { if (protocolProcessor == null) { // Get mutable HTTP processor final BasicHttpProcessor proc = getHttpProcessor(); // and create an immutable copy of it final int reqc = proc.getRequestInterceptorCount(); final HttpRequestInterceptor[] reqinterceptors = new HttpRequestInterceptor[reqc]; for (int i = 0; i < reqc; i++) { reqinterceptors[i] = proc.getRequestInterceptor(i); }/*from w w w . ja va 2 s . c o m*/ final int resc = proc.getResponseInterceptorCount(); final HttpResponseInterceptor[] resinterceptors = new HttpResponseInterceptor[resc]; for (int i = 0; i < resc; i++) { resinterceptors[i] = proc.getResponseInterceptor(i); } protocolProcessor = new ImmutableHttpProcessor(reqinterceptors, resinterceptors); } return protocolProcessor; }
From source file:org.apache.http.impl.client.AbstractStatisticsGatheringHttpClient.java
private synchronized final HttpProcessor getProtocolProcessor() { if (protocolProcessor == null) { // Get mutable HTTP processor BasicHttpProcessor proc = getHttpProcessor(); // and create an immutable copy of it int reqc = proc.getRequestInterceptorCount(); HttpRequestInterceptor[] reqinterceptors = new HttpRequestInterceptor[reqc]; for (int i = 0; i < reqc; i++) { reqinterceptors[i] = proc.getRequestInterceptor(i); }//from w ww. j a v a 2 s. c o m int resc = proc.getResponseInterceptorCount(); HttpResponseInterceptor[] resinterceptors = new HttpResponseInterceptor[resc]; for (int i = 0; i < resc; i++) { resinterceptors[i] = proc.getResponseInterceptor(i); } protocolProcessor = new ImmutableHttpProcessor(reqinterceptors, resinterceptors); } return protocolProcessor; }
From source file:org.apache.http.impl.execchain.MainClientExec.java
public MainClientExec(final HttpRequestExecutor requestExecutor, final HttpClientConnectionManager connManager, final ConnectionReuseStrategy reuseStrategy, final ConnectionKeepAliveStrategy keepAliveStrategy, final AuthenticationStrategy targetAuthStrategy, final AuthenticationStrategy proxyAuthStrategy, final UserTokenHandler userTokenHandler) { Args.notNull(requestExecutor, "HTTP request executor"); Args.notNull(connManager, "Client connection manager"); Args.notNull(reuseStrategy, "Connection reuse strategy"); Args.notNull(keepAliveStrategy, "Connection keep alive strategy"); Args.notNull(targetAuthStrategy, "Target authentication strategy"); Args.notNull(proxyAuthStrategy, "Proxy authentication strategy"); Args.notNull(userTokenHandler, "User token handler"); this.authenticator = new HttpAuthenticator(); this.proxyHttpProcessor = new ImmutableHttpProcessor(new RequestTargetHost(), new RequestClientConnControl()); this.routeDirector = new BasicRouteDirector(); this.requestExecutor = requestExecutor; this.connManager = connManager; this.reuseStrategy = reuseStrategy; this.keepAliveStrategy = keepAliveStrategy; this.targetAuthStrategy = targetAuthStrategy; this.proxyAuthStrategy = proxyAuthStrategy; this.userTokenHandler = userTokenHandler; }
From source file:org.apache.http.impl.nio.client.AbstractHttpAsyncClient.java
private synchronized final HttpProcessor getProtocolProcessor() { if (this.protocolProcessor == null) { // Get mutable HTTP processor final BasicHttpProcessor proc = getHttpProcessor(); // and upgrade an immutable copy of it final int reqc = proc.getRequestInterceptorCount(); final HttpRequestInterceptor[] reqinterceptors = new HttpRequestInterceptor[reqc]; for (int i = 0; i < reqc; i++) { reqinterceptors[i] = proc.getRequestInterceptor(i); }/* w w w. j ava 2s.co m*/ final int resc = proc.getResponseInterceptorCount(); final HttpResponseInterceptor[] resinterceptors = new HttpResponseInterceptor[resc]; for (int i = 0; i < resc; i++) { resinterceptors[i] = proc.getResponseInterceptor(i); } this.protocolProcessor = new ImmutableHttpProcessor(reqinterceptors, resinterceptors); } return this.protocolProcessor; }
From source file:org.apache.http.impl.nio.client.MainClientExec.java
public MainClientExec(final HttpProcessor httpProcessor, final HttpRoutePlanner routePlanner, final RedirectStrategy redirectStrategy, final AuthenticationStrategy targetAuthStrategy, final AuthenticationStrategy proxyAuthStrategy, final UserTokenHandler userTokenHandler) { super();//from w ww . ja v a2 s. c o m this.httpProcessor = httpProcessor; this.proxyHttpProcessor = new ImmutableHttpProcessor(new RequestTargetHost(), new RequestClientConnControl()); this.routePlanner = routePlanner; this.redirectStrategy = redirectStrategy; this.targetAuthStrategy = targetAuthStrategy; this.proxyAuthStrategy = proxyAuthStrategy; this.userTokenHandler = userTokenHandler; this.routeDirector = new BasicRouteDirector(); this.authenticator = new HttpAuthenticator(log); }