httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent());
public ListenerThread(HttpRequestHandler requestHandler, int port) { _executor = Executors.newCachedThreadPool(new NamedThreadFactory("Cluster-Listener")); try { _serverSocket = new ServerSocket(port); } catch (IOException ioex) { s_logger.error("error initializing cluster service servlet container", ioex); return; } _params = new BasicHttpParams(); _params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1"); // Set up the HTTP protocol processor BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); // Set up request handlers HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); reqistry.register("/clusterservice", requestHandler); // Set up the HTTP service _httpService = new HttpService(httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); _httpService.setParams(_params); _httpService.setHandlerResolver(reqistry); }
public ListenerThread(final ApiServer requestHandler, final int port) { try { _serverSocket = new ServerSocket(port); } catch (final IOException ioex) { s_logger.error("error initializing api server", ioex); return; } _params = new BasicHttpParams(); _params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 30000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1"); // Set up the HTTP protocol processor final BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); // Set up request handlers final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); reqistry.register("*", requestHandler); // Set up the HTTP service _httpService = new HttpService(httpproc, new NoConnectionReuseStrategy(), new DefaultHttpResponseFactory()); _httpService.setParams(_params); _httpService.setHandlerResolver(reqistry); }
protected HttpServerConnectionUpnpStream(ProtocolFactory protocolFactory, HttpServerConnection connection, final HttpParams params) { super(protocolFactory); this.connection = connection; this.params = params; // The Date header is recommended in UDA, need to document the requirement in StreamServer interface? httpProcessor.addInterceptor(new ResponseDate()); // The Server header is only required for Control so callers have to add it to UPnPMessage // httpProcessor.addInterceptor(new ResponseServer()); httpProcessor.addInterceptor(new ResponseContent()); httpProcessor.addInterceptor(new ResponseConnControl()); httpService = new UpnpHttpService( httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory() ); httpService.setParams(params); }
HttpProcessor httpProcessor = HttpProcessorBuilder.create() //.addFirst(new RequestTrace()) .add(new ResponseDate()) //.add(new ResponseServer("MyServer-HTTP/1.1")) .add(new ResponseContent()) .add(new ResponseConnControl()) .addLast(new ResposeKeepAliveHeaderMod()) .build();
public SourceConfiguration(ConfigurationContext configurationContext, TransportInDescription description, Scheme scheme, WorkerPool pool, PassThroughTransportMetricsCollector metrics) { super(configurationContext, description, pool, metrics); this.inDescription = description; this.scheme = scheme; httpProcessor = new ImmutableHttpProcessor( new HttpResponseInterceptor[]{ new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl()}); responseFactory = new DefaultHttpResponseFactory(); sourceConnections = new SourceConnections(); }
public HTTPCallbackServer(int port, int readTimeout) throws IOException { ServerSocket serverSocket = new ServerSocket(port); serverSocket.setReuseAddress(true); listener = new Listener(serverSocket); listener.setDaemon(false); params = new BasicHttpParams(); params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, readTimeout); params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false); params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); crs = new DefaultConnectionReuseStrategy(); rf = new DefaultHttpResponseFactory(); httpProcessor = new BasicHttpProcessor(); ((BasicHttpProcessor)httpProcessor).addInterceptor(new ResponseConnControl()); ((BasicHttpProcessor)httpProcessor).addInterceptor(new ResponseServer()); ((BasicHttpProcessor)httpProcessor).addInterceptor(new ResponseDate()); ((BasicHttpProcessor)httpProcessor).addInterceptor(new ResponseContent()); callbacks = new HashMap<String, HTTPCallback>(); callbacks = Collections.synchronizedMap(callbacks); }
.add(new ResponseDate()) .add(new ResponseServer("MNS-Endpoint/1.1")) .add(new ResponseContent())
/** * Return the HttpProcessor for responses * @return the HttpProcessor that processes HttpResponses of this server */ private HttpProcessor getHttpProcessor() { BasicHttpProcessor httpProcessor = new BasicHttpProcessor(); httpProcessor.addInterceptor(new ResponseDate()); httpProcessor.addInterceptor(new ResponseServer()); httpProcessor.addInterceptor(new ResponseContent()); httpProcessor.addInterceptor(new ResponseConnControl()); return httpProcessor; }
protected static HttpProcessor createDefaultProcessor() { BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); return httpproc; }
new ResponseDate(), new ResponseServer(), new ResponseContent(),
private void registerURLS() { final HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {new RequestExpectContinue()}, new HttpResponseInterceptor[] {new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl()}); final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); reqistry.register(getRegisteredURLs(), new SentiloRequestHandler(handlerLocator, authenticationService)); httpService = new HttpService(httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), reqistry, params); }
public void start(EPRuntimeSPI runtime) throws IOException { this.serversocket = new ServerSocket(this.getServiceConfig().getPort()); this.parameters = new BasicHttpParams(); this.parameters .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1"); // Set up the HTTP protocol processor BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); // Set up request handlers HttpRequestHandlerRegistry reqistry = setupRegistry(runtime); // Set up the HTTP service this.httpService = new HttpService( httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); this.httpService.setParams(this.parameters); this.httpService.setHandlerResolver(reqistry); runnable = new EsperHttpServiceClassicRunnable(this.getServiceName(), serversocket, parameters, httpService); socketThread = new Thread(runnable); socketThread.setDaemon(true); socketThread.start(); }
new ResponseContentEncoding(), new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl() }; HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
public ListenerThread(final HttpRequestHandler requestHandler, final int port) { _executor = Executors.newCachedThreadPool(new NamedThreadFactory("Cluster-Listener")); try { _serverSocket = new ServerSocket(port); } catch (final IOException ioex) { s_logger.error("error initializing cluster service servlet container", ioex); return; } _params = new BasicHttpParams(); _params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1"); // Set up the HTTP protocol processor final BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); // Set up request handlers final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); reqistry.register("/clusterservice", requestHandler); // Set up the HTTP service _httpService = new HttpService(httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); _httpService.setParams(_params); _httpService.setHandlerResolver(reqistry); }
httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent());
private void initHttpServer() { try { serversocket = new ServerSocket(port); serversocket.setReuseAddress(true); //设置 http 参数 params = new BasicHttpParams(); params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5 * 1000) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1"); BasicHttpProcessor httpProcessor = new BasicHttpProcessor();//http协议处理器 httpProcessor.addInterceptor(new ResponseDate());//http协议拦截器,响应日期 httpProcessor.addInterceptor(new ResponseServer());//响应服务器 httpProcessor.addInterceptor(new ResponseContent());//响应内容 httpProcessor.addInterceptor(new ResponseConnControl());//响应连接控制 //http请求处理程序解析器 HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry(); //http请求处理程序,HttpFileHandler继承于HttpRequestHandler(http请求处理程序) registry.register(Constant.Http.BROWSE, new FileBrowseHandler(webRoot,context)); httpService = new HttpService(httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); httpService.setParams(params); httpService.setHandlerResolver(registry);//为http服务设置注册好的请求处理器。 } catch (IOException e) { e.printStackTrace(); this.interrupt(); } }
HttpResponseInterceptor[] responseInterceptors = new HttpResponseInterceptor[] { new ResponseContentEncoding(), new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl() }; HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
public RequestListenerThread(final int port) throws IOException { logger.info("Starting proxy listener thread on " + port); this.serversocket = new ServerSocket(port); // Set up HTTP protocol processor for incoming connections final HttpProcessor inhttpproc = new ImmutableHttpProcessor( new ResponseDate(), new ResponseServer("Test/1.1"), new ResponseContent(), new ResponseConnControl()); // Set up HTTP protocol processor for outgoing connections final HttpProcessor outhttpproc = new ImmutableHttpProcessor( new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent("Test/1.1"), new RequestExpectContinue(true)); // Set up outgoing request executor final HttpRequestExecutor httpexecutor = new HttpRequestExecutor(); // Set up incoming request handler final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper(); reqistry.register("*", new ProxyHandler( outhttpproc, httpexecutor)); // Set up the HTTP service (the listener) this.httpService = new HttpService(inhttpproc, reqistry); }