List of usage examples for org.apache.http.impl DefaultHttpResponseFactory DefaultHttpResponseFactory
public DefaultHttpResponseFactory()
From source file:es.tid.fiware.rss.oauth.test.ResponseHandlerTest.java
/** * // w ww . ja va 2 s . co m */ @Test public void handleResponseTest() throws Exception { ResponseHandler handler = new ResponseHandler(); HttpResponseFactory factory = new DefaultHttpResponseFactory(); HttpResponse responseSent = factory .newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "reason"), null); HttpResponse response = handler.handleResponse(responseSent); Assert.assertEquals(handler.getStatus(), HttpStatus.SC_OK); Assert.assertFalse(handler.hasContent()); // response with content. BasicHttpEntity entity = new BasicHttpEntity(); InputStream inputStream = new ByteArrayInputStream("new content".getBytes()); entity.setContent(inputStream); entity.setContentLength("new content".length()); // sets the length response.setEntity(entity); response = handler.handleResponse(responseSent); Assert.assertEquals("new content", handler.getResponseContent()); }
From source file:neembuu.httpserver.VFStoHttpServer.java
private void create(int port) throws IOException { HttpProcessor httpproc = new BasicHttpProcessor(); HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry(); registry.register("*", new VFSHandler(fs)); HttpService httpService = new HttpService(httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); httpService.setHandlerResolver(registry); SSLServerSocketFactory sf = null; Thread t = new RequestListenerThread(port, httpService, sf); t.setDaemon(false);//from w w w . j a v a2 s. co m t.start(); }
From source file:com.wondershare.http.core.Dispatcher.java
protected void initHttpService() { BasicHttpProcessor proc = new BasicHttpProcessor(); ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy(); HttpResponseFactory responseFactory = new DefaultHttpResponseFactory(); proc.addInterceptor(new ResponseDate()); proc.addInterceptor(new ResponseServer()); proc.addInterceptor(new ResponseContent()); proc.addInterceptor(new ResponseConnControl()); httpService = new HttpService(proc, connStrategy, responseFactory); }
From source file:org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.java
public void connected(final IOSession session) { // Decorate I/O session with logging capabilities LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(session), new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY); this.handler.connected(conn, attachment); }
From source file:org.hydracache.server.httpd.HttpServiceHandlerFactory.java
public NHttpServiceHandler create() throws Exception { BasicHttpProcessor httpproc = new BasicHttpProcessor(); // Required protocol interceptors httpproc.addInterceptor(new ResponseDate()); httpproc.addInterceptor(new ResponseServer()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); httpproc.addInterceptor(new ParameterFetchRequestIntercepter()); BufferingHttpServiceHandler handler = new BufferingHttpServiceHandler(httpproc, new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(), httpParams); HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); reqistry.register("*", requestHandler); handler.setHandlerResolver(reqistry); handler.setEventListener(protocolEventListener); return handler; }
From source file:org.siddhiesb.transport.http.conn.ClientConnFactory.java
public ClientConnFactory(final HttpResponseFactory responseFactory, final ByteBufferAllocator allocator, final SSLContextDetails ssl, final Map<String, SSLContext> sslByHostMap, final HttpParams params) { super();/* w ww .j a v a 2 s.c o m*/ this.responseFactory = responseFactory != null ? responseFactory : new DefaultHttpResponseFactory(); this.allocator = allocator != null ? allocator : new HeapByteBufferAllocator(); this.ssl = ssl; this.sslByHostMap = sslByHostMap != null ? new ConcurrentHashMap<String, SSLContext>(sslByHostMap) : null; this.params = params != null ? params : new BasicHttpParams(); }
From source file:com.wentam.defcol.connect_to_computer.WebServer.java
public WebServer(Context context, String jquery) { this.setContext(context); 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("/", new HomeCommandHandler(context, jquery)); httpService.setHandlerResolver(registry); }
From source file:com.personalserver.HttpThread.java
public HttpThread(Context ctx, Socket soket, String threadName) { this.mContext = ctx; this.mSocket = soket; this.setName(threadName); mHttpProcessor = new BasicHttpProcessor(); mHttpContext = new BasicHttpContext(); mHttpProcessor.addInterceptor(new ResponseDate()); mHttpProcessor.addInterceptor(new ResponseServer()); mHttpProcessor.addInterceptor(new ResponseContent()); mHttpProcessor.addInterceptor(new ResponseConnControl()); mHttpService = new HttpService(mHttpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory()); mHttpRequestHandlerRegistry = new HttpRequestHandlerRegistry(); mHttpRequestHandlerRegistry.register(ALL_PATTERN, new HomeCommandHandler(ctx)); mHttpRequestHandlerRegistry.register(DIR_PATTERN, new DirCommandHandler(ctx)); mHttpService.setHandlerResolver(mHttpRequestHandlerRegistry); }
From source file:ru.apertum.qsystem.reports.net.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); }
From source file:org.apache.axis2.transport.nhttp.SSLClientIOEventDispatch.java
public void connected(final IOSession session) { SSLIOSession sslSession = new SSLIOSession(session, this.sslcontext, this.sslHandler); LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(sslSession), new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); session.setAttribute(SSL_SESSION, sslSession); Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY); this.handler.connected(conn, attachment); try {//from w ww . ja v a 2 s. c o m sslSession.bind(SSLMode.CLIENT, this.params); } catch (SSLException ex) { this.handler.exception(conn, ex); sslSession.shutdown(); } }