Java 类org.apache.http.protocol.HttpService 实例源码
项目:sbc-qsystem
文件:QSystemHtmlInstance.java
private QSystemHtmlInstance() {
this.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, "QSystemReportHttpServer/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("*", new HttpQSystemReportsHandler());
// Set up the HTTP service
this.httpService = new HttpService(
httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory(), reqistry, this.params);
}
项目:Camel
文件:HttpTestServer.java
/**
* Creates a new test server.
*
* @param proc the HTTP processors to be used by the server, or
* <code>null</code> to use a
* {@link #newProcessor default} processor
* @param reuseStrat the connection reuse strategy to be used by the
* server, or <code>null</code> to use
* {@link #newConnectionReuseStrategy() default}
* strategy.
* @param params the parameters to be used by the server, or
* <code>null</code> to use
* {@link #newDefaultParams default} parameters
* @param sslcontext optional SSL context if the server is to leverage
* SSL/TLS transport security
*/
public HttpTestServer(
final BasicHttpProcessor proc,
final ConnectionReuseStrategy reuseStrat,
final HttpResponseFactory responseFactory,
final HttpExpectationVerifier expectationVerifier,
final HttpParams params,
final SSLContext sslcontext) {
this.handlerRegistry = new HttpRequestHandlerRegistry();
this.workers = Collections.synchronizedSet(new HashSet<Worker>());
this.httpservice = new HttpService(
proc != null ? proc : newProcessor(),
reuseStrat != null ? reuseStrat : newConnectionReuseStrategy(),
responseFactory != null ? responseFactory : newHttpResponseFactory(),
handlerRegistry,
expectationVerifier,
params != null ? params : newDefaultParams());
this.sslcontext = sslcontext;
}
项目:dsworkbench
文件:ReportServer.java
public RequestListenerThread(int port, final String docroot) throws IOException {
this.serversocket = new ServerSocket(port);
this.params = new SyncBasicHttpParams();
this.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
HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]{
new ResponseDate(),
new ResponseServer(),
new ResponseContent(),
new ResponseConnControl()
});
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler());
// Set up the HTTP service
this.httpService = new HttpService(
httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory(),
reqistry,
this.params);
}
项目:dlna-for-android
文件:HttpServer.java
public ListenerThread(InetAddress address, int port, HttpParams params,
HttpRequestHandlerRegistry handlerRegistry) throws IOException {
this.params = params;
this.serverSocket = new ServerSocket(port, 0, address);
BasicHttpProcessor httpproc = new BasicHttpProcessor();
httpproc.addInterceptor(new ResponseDate());
httpproc.addInterceptor(new ResponseServer());
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseConnControl());
this.httpService = new HttpService(httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory());
this.httpService.setParams(params);
this.httpService.setHandlerResolver(handlerRegistry);
}
项目:OpsDev
文件:ElementalHttpServer.java
public RequestListenerThread(
int port,
HttpService httpService,
SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
while (!createServerSocket(sf, port))
{
port++;
if (port >= 65535) {
System.out.println("Now the port is already in use,port number add 1");
ConsoleFactory.printToConsole("Now the port is already in use,port number add 1",true);
break;
}
}
monitorPort = port;
this.httpService = httpService;
}
项目:haogrgr-test
文件:HttpSrvMain.java
public static void main(String[] args) throws Exception {
int port = 8080;
String docRoot = "D:\\svn_file\\TEST2\\150503\\web-customer";
// Set up the HTTP protocol processor
HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate())
.add(new ResponseServer("Haogrgr/1.1")).add(new ResponseContent())
.add(new ResponseConnControl()).build();
// Set up request handlers
UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new HttpFileHandler(docRoot));
// Set up the HTTP service
HttpService httpService = new HttpService(httpproc, reqistry);
Thread t = new RequestListenerThread(port, httpService, null);
t.setDaemon(false);
t.start();
}
项目:gen-server-http-listener
文件:RequestListenerThread.java
/**
* Default constructor which specifies the <code>port</code> to listen to
* for requests and the <code>handlers</code>, which specify how to handle
* the request.
*
* @param port
* the port to listen to
* @param handlers
* the handlers, which specify how to handle the different
* requests
*
* @throws IOException
* if some IO operation fails
*/
public RequestListenerThread(final int port,
final Map<String, IHandler> handlers) throws IOException {
super(port);
// Set up the HTTP protocol processor
final HttpProcessor httpproc = new ImmutableHttpProcessor(
new HttpResponseInterceptor[] { new ResponseDate(),
new ResponseServer(), new ResponseContent(),
new ResponseConnControl() });
// Set up request handlers
UriHttpRequestHandlerMapper registry = new UriHttpRequestHandlerMapper();
for (final Entry<String, IHandler> entry : handlers.entrySet()) {
registry.register(entry.getKey(), entry.getValue());
}
// Set up the HTTP service
httpService = new HttpService(httpproc, registry);
connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
}
项目:CadalWorkspace
文件:Httpd.java
public RequestListenerThread(int port, final String docroot) throws IOException {
this.serversocket = new ServerSocket(port);
this.params = new BasicHttpParams();
this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 1000).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
HttpProcessor httpproc = new BasicHttpProcessor();
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler(docroot));
// Set up the HTTP service
this.httpService = new HttpService(httpproc, new NoConnectionReuseStrategy(), new DefaultHttpResponseFactory());
this.httpService.setParams(this.params);
this.httpService.setHandlerResolver(reqistry);
}
项目:CadalWorkspace
文件:Httpd.java
public RequestListenerThread(int port, final String docroot) throws IOException {
this.serversocket = new ServerSocket(port);
this.params = new BasicHttpParams();
this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 1000).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
HttpProcessor httpproc = new BasicHttpProcessor();
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler(docroot));
// Set up the HTTP service
this.httpService = new HttpService(httpproc, new NoConnectionReuseStrategy(), new DefaultHttpResponseFactory());
this.httpService.setParams(this.params);
this.httpService.setHandlerResolver(reqistry);
}
项目:outcomes
文件:TestHttpCore.java
@Test
public void test() throws ExecutionException, InterruptedException {
HttpHost target = new HttpHost("localhost");
BasicConnPool connpool = new BasicConnPool();
connpool.setMaxTotal(200);
connpool.setDefaultMaxPerRoute(10);
connpool.setMaxPerRoute(target, 20);
Future<BasicPoolEntry> future = connpool.lease(target, null);
BasicPoolEntry poolEntry = future.get();
HttpClientConnection conn = poolEntry.getConnection();
HttpProcessor httpproc = HttpProcessorBuilder.create()
.add(new ResponseDate())
.add(new ResponseServer("MyServer-HTTP/1.1"))
.add(new ResponseContent())
.add(new ResponseConnControl())
.build();
HttpRequestHandler myRequestHandler = new HttpRequestHandler() {
public void handle(
HttpRequest request,
HttpResponse response,
HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
response.setEntity(
new StringEntity("some important message",
ContentType.TEXT_PLAIN));
}
};
UriHttpRequestHandlerMapper handlerMapper = new UriHttpRequestHandlerMapper();
handlerMapper.register("/service/*", myRequestHandler);
HttpService httpService = new HttpService(httpproc, handlerMapper);
}
项目:PhET
文件:ElementalHttpServer.java
public RequestListenerThread(int port, final String docroot) throws IOException {
this.serversocket = new ServerSocket(port);
this.params = new SyncBasicHttpParams();
this.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
HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
new ResponseContent(),
new ResponseConnControl()
});
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler(docroot));
// Set up the HTTP service
this.httpService = new HttpService(
httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory(),
reqistry,
this.params);
}
项目:PhET
文件:ElementalHttpServer.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:PhET
文件:ElementalReverseProxy.java
public ProxyThread(
final HttpService httpservice,
final HttpServerConnection inconn,
final HttpClientConnection outconn) {
super();
this.httpservice = httpservice;
this.inconn = inconn;
this.outconn = outconn;
}
项目:cosmic
文件:ApiServer.java
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);
}
项目:cosmic
文件:ClusterServiceServletContainer.java
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);
}
项目:java-binrepo-proxy
文件:ElementalReverseProxy.java
public RequestListenerThread(final int port, final HttpHost target) throws IOException {
this.target = target;
this.serversocket = new ServerSocket(port);
// Set up HTTP protocol processor for incoming connections
final HttpProcessor inhttpproc = new ImmutableHttpProcessor(
new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
new RequestConnControl(),
new RequestUserAgent("Test/1.1"),
new RequestExpectContinue(true)
});
// Set up HTTP protocol processor for outgoing connections
final HttpProcessor outhttpproc = new ImmutableHttpProcessor(
new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer("Test/1.1"),
new ResponseContent(),
new ResponseConnControl()
});
// Set up outgoing request executor
final HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
// Set up incoming request handler
final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new ProxyHandler(
this.target,
outhttpproc,
httpexecutor));
// Set up the HTTP service
this.httpService = new HttpService(inhttpproc, reqistry);
}
项目:java-binrepo-proxy
文件:ElementalReverseProxy.java
public ProxyThread(
final HttpService httpservice,
final HttpServerConnection inconn,
final HttpClientConnection outconn) {
super();
this.httpservice = httpservice;
this.inconn = inconn;
this.outconn = outconn;
}
项目:java-binrepo-proxy
文件:HttpCoreTransportServer.java
public RequestListenerThread(final int port, final HttpHost target, final TransportHandler handler) throws IOException {
this.target = target;
this.serversocket = new ServerSocket(port);
// Set up HTTP protocol processor for incoming connections
final HttpProcessor inhttpproc = new ImmutableHttpProcessor(
new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
new RequestConnControl(),
new RequestUserAgent("Test/1.1"),
new RequestExpectContinue(true)
});
// Set up HTTP protocol processor for outgoing connections
final HttpProcessor outhttpproc = new ImmutableHttpProcessor(
new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer("Test/1.1"),
new ResponseContent(),
new ResponseConnControl()
});
// Set up outgoing request executor
final HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
// Set up incoming request handler
final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new ProxyHandler(
this.target,
outhttpproc,
httpexecutor,
handler));
// Set up the HTTP service
this.httpService = new HttpService(inhttpproc, reqistry);
}
项目:dsworkbench
文件:ReportServer.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:hssd
文件:RequestListenerThread.java
public RequestListenerThread(int port, String docRoot)
throws IOException {
this.docRoot = docRoot;
this.serversocket = new ServerSocket(port);
this.params = new SyncBasicHttpParams();
this.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
HttpProcessor httpproc = new ImmutableHttpProcessor(
new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
new ResponseContent(),
new ResponseConnControl()
});
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler(docRoot));
// Set up the HTTP service
this.httpService = new HttpService(
httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory(),
reqistry,
this.params);
this.serversocket.setSoTimeout(3000);
}
项目:hssd
文件:WorkerThread.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:Blackhole
文件:WebServer.java
public WebServer(Context context){
super(SERVER_NAME);
this.setContext(context);
serverPort = WebServer.DEFAULT_SERVER_PORT;
httpproc = new BasicHttpProcessor();
httpContext = new BasicHttpContext();
httpproc.addInterceptor(new ResponseDate());
httpproc.addInterceptor(new ResponseServer());
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseConnControl());
httpService = new HttpService(httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory());
registry = new HttpRequestHandlerRegistry();
registry.register(ALL_PATTERN, new AssetHandler(context));
registry.register(HOME_PATTERN, new ListingHandler(context));
registry.register(NONE_PATTERN, new ListingHandler(context));
registry.register(DIR_PATTERN, new ListingHandler(context));
registry.register(FILE_PATTERN, new FileHandler(context));
registry.register(GETAPK_PATTERN, new GetApkHandler(context));
registry.register(UPLOAD_PATTERN, new UploadHandler(context));
registry.register(DOWNLOAD_ALL_PATTERN, new DownloadAllHandler(context));
httpService.setHandlerResolver(registry);
}
项目:OpsDev
文件:ElementalHttpServer.java
public static void startServer(int port) {
// 设置端口号 后期需要对端口号进行判断是否已经被占用,并把端口号信息写进模板中
isRun = true;
// Set up the HTTP protocol processor
HttpProcessor httpproc = HttpProcessorBuilder.create()
.add(new ResponseDate())
.add(new ResponseServer("Test/1.1"))
.add(new ResponseContent())
.add(new ResponseConnControl()).build();
// Set up request handlers
UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new HttpFileHandler(null));
// Set up the HTTP service
httpService = new HttpService(httpproc, reqistry);
SSLServerSocketFactory sf = null;
try {
t = new RequestListenerThread(port, httpService, sf);
} catch (IOException e) {
e.printStackTrace();
}
t.setDaemon(true);
t.start();
}
项目:OpsDev
文件:ElementalHttpServer.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:SparrowWorker
文件:ConnectionHandlerThread.java
ConnectionHandlerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:SparrowWorker
文件:RequestListenerThread.java
public RequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(100);
System.out.println("Request Listener Thread created");
}
项目:SparrowScheduler
文件:GenericRequestListenerThread.java
public GenericRequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(1000);
//System.out.println("Request Listener Thread created");
}
项目:SparrowScheduler
文件:LateBindingRequestListenerThread.java
public LateBindingRequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(22);
System.out.println("Request Listener Thread created");
}
项目:SparrowScheduler
文件:ConnectionHandlerThread.java
ConnectionHandlerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:cim
文件:WorkerThread.java
public WorkerThread(HttpService httpservice, HttpServerConnection conn,
OnWebServListener listener) {
super();
this.httpservice = httpservice;
this.conn = conn;
this.listener = listener;
}
项目:cloudstack
文件:ApiServer.java
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);
}
项目:cloudstack
文件:ClusterServiceServletContainer.java
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);
}
项目:jntlm
文件:ProxyProxy.java
ProxyProxy(int listenPort, InetAddress listenAddress, HttpHost proxy) throws IOException {
this.serversocket = new ServerSocket(listenPort, 0, listenAddress);
HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseConnControl()).build();
UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new HttpForwardingHandler(proxy));
this.httpService = new HttpService(httpproc, new UpgradedConnectionAwareReusingStrategy(), null, reqistry);
}
项目:dcl
文件:WorkerThread.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}
项目:opentravelmate
文件:HttpServer.java
/**
* Create a server socket on an available port and process the requests.
*/
public void start() throws IOException {
// Prepare the HTTP server
this.serverSocket = new ServerSocket(0);
HttpParams httpParams = new BasicHttpParams()
.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");
BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
httpProcessor.addInterceptor(new ResponseDate());
httpProcessor.addInterceptor(new ResponseServer());
httpProcessor.addInterceptor(new ResponseContent());
httpProcessor.addInterceptor(new ResponseConnControl());
HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();
for (Map.Entry<String, HttpRequestHandler> entry : requestHandlerByPattern.entrySet()) {
registry.register(entry.getKey(), entry.getValue());
}
HttpService httpService = new HttpService(httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory());
httpService.setParams(httpParams);
httpService.setHandlerResolver(registry);
// Handle incoming connections
executorService.execute(new RequestListener(this.serverSocket, httpParams, httpService, executorService, exceptionListener));
}
项目:opentravelmate
文件:HttpServer.java
/**
* Create a request listener.
*
* @param serverSocket
* @param httpParams
* @param httpService
* @param executorService
* @param exceptionListener
*/
public RequestListener(
ServerSocket serverSocket,
HttpParams httpParams,
HttpService httpService,
ExecutorService executorService,
ExceptionListener exceptionListener) {
this.serverSocket = serverSocket;
this.httpParams = httpParams;
this.httpService = httpService;
this.executorService = executorService;
this.exceptionListener = exceptionListener;
}
项目:Megapode
文件:HttpServer.java
public RequestListenerThread(final int port,
final HttpService httpService, final SSLServerSocketFactory sf)
throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port)
: new ServerSocket(port);
this.httpService = httpService;
LimitedQueue<Runnable> blockingQueue = new LimitedQueue<Runnable>(
10);
executor = new java.util.concurrent.ThreadPoolExecutor(1, 10, 0L,
TimeUnit.MILLISECONDS, blockingQueue);
}
项目:AndroidWebServ
文件:WorkerThread.java
public WorkerThread(HttpService httpservice, HttpServerConnection conn,
OnWebServListener listener) {
super();
this.httpservice = httpservice;
this.conn = conn;
this.listener = listener;
}
项目:tunebot
文件:WebServer.java
public RequestListenerThread(int port) throws IOException {
this.serversocket = new ServerSocket(port);
this.params = new SyncBasicHttpParams();
this.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
HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
new ResponseContent(),
new ResponseConnControl()
});
// Set up request handlers
HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
reqistry.register("*", new HttpFileHandler());
// Set up the HTTP service
this.httpService = new HttpService(
httpproc,
new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory(),
reqistry,
this.params);
}
项目:tunebot
文件:WebServer.java
public WorkerThread(
final HttpService httpservice,
final HttpServerConnection conn) {
super();
this.httpservice = httpservice;
this.conn = conn;
}