protected HttpResponseFactory createHttpResponseFactory() { return new DefaultHttpResponseFactory(); }
@Override protected String sendAndReturn(final HttpUriRequest request) throws IOException { final HttpResponseFactory factory = new DefaultHttpResponseFactory(); final HttpResponse response = factory.newHttpResponse( new BasicStatusLine(HttpVersion.HTTP_1_1, this.status, null), null); final StringBuilder sb = new StringBuilder(); sb.append(String.format("%s = %s;", "METHOD", request.getMethod())); sb.append(String.format("%s = %s;", "URI", request.getURI())); final HttpEntity entity = ((HttpEntityEnclosingRequestBase) request).getEntity(); sb.append(String.format("%s = %s;", "BODY", EntityUtils.toString(entity))); response.setEntity(new StringEntity(sb.toString())); return parseResponse(response); }
httpproc.addInterceptor(new ResponseConnControl()); BufferingHttpServiceHandler handler = new BufferingHttpServiceHandler(httpproc, new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(), params);
httpproc.addInterceptor(new ResponseConnControl()); BufferingHttpServiceHandler handler = new BufferingHttpServiceHandler(httpproc, new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(), params);
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); }
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); }
public HttpResponseFactory newResponseFactory() { return new DefaultHttpResponseFactory(); }
protected HttpResponseFactory createHttpResponseFactory() { return new DefaultHttpResponseFactory(); }
public MyHandler(HttpParams params, String path) { this(params, path, new DefaultHttpResponseFactory()); }
protected HttpResponseFactory createHttpResponseFactory() { return new DefaultHttpResponseFactory(); }
public HttpResponseFactory newResponseFactory() { return new DefaultHttpResponseFactory(); }
protected HttpResponseFactory createHttpResponseFactory() { return new DefaultHttpResponseFactory(); }
protected HttpResponseFactory createHttpResponseFactory() { return new DefaultHttpResponseFactory(); }
import org.apache.http.HttpStatus; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseFactory; import org.apache.http.HttpVersion; import org.apache.http.impl.DefaultHttpResponseFactory; import org.apache.http.message.BasicStatusLine; HttpResponseFactory factory = new DefaultHttpResponseFactory(); HttpResponse response = factory.newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null), null);
import org.apache.http.impl.DefaultHttpResponseFactory; import org.json.JSONObject; HttpResponseFactory factory = new DefaultHttpResponseFactory(); org.apache.http.HttpResponse response = factory.newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null), null); JSONObject json = new JSONObject(); json.put("result", "10"); response.setEntity(new StringEntity(json.toString())); com.mashape.unirest.http.HttpResponse<JsonNode> httpResponse = new HttpResponse<JsonNode>(response, JsonNode.class);
public ClientConnFactory( final HttpResponseFactory responseFactory, final ByteBufferAllocator allocator, final SSLContextDetails ssl, final Map<String, SSLContext> sslByHostMap, final HttpParams params) { super(); 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(); }
public AsyncBufferingHttpServiceHandler(final HttpParams params) { super(createDefaultProcessor(), new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(), params); }
public WebdavConnection(Socket socket, SocketInputBuffer input, SocketOutputBuffer output, HttpParams params) { this.socket = socket; this.entityserializer = new EntitySerializer(new StrictContentLengthStrategy()); this.entitydeserializer = new EntityDeserializer(new LaxContentLengthStrategy()); this.input = input; this.output = output; this.responseParser = new HttpResponseParser(input, null, new DefaultHttpResponseFactory(), params); this.requestWriter = new HttpRequestWriter(output, null, params); this.metrics = new HttpConnectionMetricsImpl(input.getMetrics(), output.getMetrics()); this.open = true; }
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); }