Java 类org.apache.http.impl.DefaultHttpResponseFactory 实例源码

项目: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);
}
项目:yaacc-code    文件:YaaccUpnpServerService.java   
public RequestListenerThread(Context context) throws IOException, BindException {
    serversocket = new ServerSocket(PORT);
    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 httpProcessor = new BasicHttpProcessor();
    httpProcessor.addInterceptor(new ResponseDate());
    httpProcessor.addInterceptor(new ResponseServer());
    httpProcessor.addInterceptor(new ResponseContent());
    httpProcessor.addInterceptor(new ResponseConnControl());

    // Set up the HTTP service
    this.httpService = new YaaccHttpService(httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), context);

}
项目: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);
}
项目:DroidDLNA    文件:HttpServerConnectionUpnpStream.java   
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);
}
项目: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);
}
项目:fiware-rss    文件:ResponseHandlerTest.java   
/**
 * 
 */
@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());
}
项目:bintray-client-java    文件:BintrayImpl.java   
public HttpResponse put(Map<String, InputStream> uriAndStreamMap, Map<String, String> headers) throws MultipleBintrayCallException {
    List<Future<String>> executions = new ArrayList<>();
    List<BintrayCallException> errors = new ArrayList<>();
    List<RequestRunner> runners = createPutRequestRunners(uriAndStreamMap, headers, errors);
    try {
        executions = executorService.invokeAll(runners);
    } catch (InterruptedException e) {
        BintrayCallException bce = new BintrayCallException(409, e.getMessage(), (e.getCause() == null) ? ""
                : e.getCause().toString() + " : " + e.getCause().getMessage());
        log.error(bce.toString());
        log.debug("{}", e.getMessage(), e);
        errors.add(bce);
    }
    collectResults(executions, errors);

    //Return ok or throw errors
    if (errors.isEmpty()) {
        String entity = "Operation Successful";
        HttpResponse response = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(
                new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_CREATED, new HttpClientContext());
        response.setEntity(new StringEntity(entity, Charset.forName("UTF-8")));
        return response;
    } else {
        throw new MultipleBintrayCallException(errors);
    }
}
项目: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);
}
项目: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);
}
项目: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);
}
项目:azkaban    文件:RestfulApiClientTest.java   
@Override
protected String sendAndReturn(HttpUriRequest request) throws IOException{
  HttpResponseFactory factory = new DefaultHttpResponseFactory();

  HttpResponse response = factory.newHttpResponse(
      new BasicStatusLine(HttpVersion.HTTP_1_1, this.status, null),null);

  StringBuilder sb = new StringBuilder();
  sb.append(String.format("%s = %s;", "METHOD", request.getMethod()));
  sb.append(String.format("%s = %s;", "URI", request.getURI()));

  if (request.getAllHeaders().length > 0){
    sb.append("HEADER_EXISTS");
  }

  for (Header h : request.getAllHeaders()){
    sb.append(String.format("%s = %s;", h.getName(), h.getValue()));
  }

  if (request instanceof HttpEntityEnclosingRequestBase){
    HttpEntity entity = ((HttpEntityEnclosingRequestBase)request).getEntity();
    if (entity != null){
      sb.append("BODY_EXISTS");
      sb.append(String.format("%s = %s;", "BODY", EntityUtils.toString(entity)));
    }
  }

  response.setEntity(new StringEntity(sb.toString()));
  return parseResponse(response);
}
项目:vespa    文件:CoredumpHandlerTest.java   
private void setNextHttpResponse(int code, Optional<String> message) throws IOException {
    DefaultHttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
    HttpResponse httpResponse = responseFactory.newHttpResponse(
            new BasicStatusLine(HttpVersion.HTTP_1_1, code, null), null);
    if (message.isPresent()) httpResponse.setEntity(new StringEntity(message.get()));

    when(httpClient.execute(any())).thenReturn(httpResponse);
}
项目:Android_CCTV    文件:TinyHttpServer.java   
protected RequestListener() throws Exception {

            mHttpService = new org.apache.http.protocol.HttpService(
                    mHttpProcessor, 
                    new DefaultConnectionReuseStrategy(), 
                    new DefaultHttpResponseFactory());
            mHttpService.setHandlerResolver(mRegistry);
            mHttpService.setParams(mParams);

        }
项目:purecloud-iot    文件:DefaultHttpResponseParserFactory.java   
public DefaultHttpResponseParserFactory(
        final LineParser lineParser,
        final HttpResponseFactory responseFactory) {
    super();
    this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
    this.responseFactory = responseFactory != null ? responseFactory
            : DefaultHttpResponseFactory.INSTANCE;
}
项目:esper    文件:EsperHttpServiceClassic.java   
public void start(EPServiceProviderSPI engine) 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(engine);

    // 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();
}
项目:esper    文件:SupportHTTPServer.java   
public void start() throws Exception {
    if (serversocket != null) {
        throw new RuntimeException("Server socket already initialized");
    }

    this.serversocket = new ServerSocket(port);
    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 registery = new HttpRequestHandlerRegistry();
    registery.register("*", new SupportHTTPServerReqestHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc,
            new DefaultConnectionReuseStrategy(),
            new DefaultHttpResponseFactory());
    this.httpService.setParams(this.parameters);
    this.httpService.setHandlerResolver(registery);

    runnable = new EsperHttpServiceClassicRunnable("regressionTestService", serversocket, parameters, httpService);
    socketThread = new Thread(runnable);
    socketThread.setDaemon(true);
    socketThread.start();
}
项目: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);
}
项目: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);
}
项目:wso2-axis2    文件:DefaultConnectionListener.java   
public void run() {
    try {
        while (!Thread.interrupted()) {
            try {
                if (serversocket == null || serversocket.isClosed()) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Listening on port " + port);
                    }
                    serversocket = new ServerSocket(port);
                    serversocket.setReuseAddress(true);
                }
                LOG.debug("Waiting for incoming HTTP connection");
                Socket socket = this.serversocket.accept();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Incoming HTTP connection from " +
                            socket.getRemoteSocketAddress());
                }
                AxisHttpConnection conn = new AxisHttpConnectionImpl(socket, this.params);
                try {
                    this.connmanager.process(conn);
                } catch (RejectedExecutionException e) {
                    conn.sendResponse(new DefaultHttpResponseFactory().newHttpResponse(
                            HttpVersion.HTTP_1_0, HttpStatus.SC_SERVICE_UNAVAILABLE, new BasicHttpContext(null)));
                }
            } catch(java.io.InterruptedIOException ie) {
                break;
            } catch (Throwable ex) {
                if (Thread.interrupted()) {
                    break;
                }
                if (!failureHandler.failed(this, ex)) {
                    break;
                }
            }
        }
    } finally {
        destroy();
    }
}
项目:carbon-platform-integration    文件:SimpleHttpServer.java   
public void start() throws IOException {
    serverSocket = new ServerSocket(port);
    params = new BasicHttpParams();
    params
            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
                    getParameter(CoreConnectionPNames.SO_TIMEOUT, 60000))
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
                    getParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024))
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,
                    getParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, 0) == 1)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,
                    getParameter(CoreConnectionPNames.TCP_NODELAY, 1) == 1)
            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "WSO2ESB-Test-Server");
    // Configure HTTP protocol processor
    BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
    httpProcessor.addInterceptor(new ResponseDate());
    httpProcessor.addInterceptor(new ResponseServer());
    httpProcessor.addInterceptor(new ResponseContent());
    httpProcessor.addInterceptor(new ResponseConnControl());
    HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();
    registry.register("*", requestHandler);
    // Set up the HTTP service
    httpService = new HttpService(
            httpProcessor,
            new DefaultConnectionReuseStrategy(),
            new DefaultHttpResponseFactory(), registry, params);
    listener = Executors.newSingleThreadExecutor();
    workerPool = Executors.newFixedThreadPool(getParameter("ThreadCount", 2));
    shutdown = false;
    listener.submit(new HttpListener());
}
项目: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);
}
项目:bintray-client-java    文件:BintrayImpl.java   
/**
 * Executes a sign request using the ExecutorService and uses the file count to set a timeout to avoid timing out
 * on long requests
 *
 * @throws BintrayCallException
 */
public HttpResponse sign(String uri, Map<String, String> headers, int fileCount) throws BintrayCallException {
    HttpPost signRequest = new HttpPost(createUrl(uri));
    setHeaders(signRequest, headers);
    signRequest.setConfig(RequestConfig.custom().setSocketTimeout(signRequestTimeoutPerFile * fileCount)
            .setConnectionRequestTimeout(signRequestTimeoutPerFile * fileCount)
            .setConnectTimeout(signRequestTimeoutPerFile * fileCount).build());
    RequestRunner runner = new RequestRunner(signRequest, client, responseHandler);
    Future<String> signResponse = executorService.submit(runner);
    try {
        signResponse.get();
    } catch (Exception e) {
        BintrayCallException bce;
        if (e.getCause() instanceof BintrayCallException) {
            bce = (BintrayCallException) e.getCause();
        } else {
            bce = new BintrayCallException(409, e.getMessage(), (e.getCause() == null) ? ""
                    : ", " + e.getCause().toString() + " : " + e.getCause().getMessage());
        }
        log.error(bce.toString());
        log.debug("{}", e.getMessage(), e);
        throw bce;
    }

    //Return ok
    String entity = "Signing the version was successful";
    HttpResponse response = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(
            new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_CREATED, new HttpClientContext());
    response.setEntity(new StringEntity(entity, Charset.forName("UTF-8")));
    return response;
}
项目:bintray-client-java    文件:BintrayImpl.java   
@Override
public HttpResponse handleResponse(HttpResponse response) throws BintrayCallException {
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusNotOk(statusCode)) {
        BintrayCallException bce = new BintrayCallException(response);

        //We're using CloseableHttpClient so it's ok
        HttpClientUtils.closeQuietly((CloseableHttpResponse) response);
        throw bce;
    }

    //Response entity might be null, 500 and 405 also give the html itself so skip it
    byte[] entity = new byte[0];
    if (response.getEntity() != null && statusCode != 500 && statusCode != 405) {
        try {
            entity = IOUtils.toByteArray(response.getEntity().getContent());
        } catch (IOException | NullPointerException e) {
            //Null entity - Ignore
        } finally {
            HttpClientUtils.closeQuietly((CloseableHttpResponse) response);
        }
    }

    HttpResponse newResponse = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(response.getStatusLine(),
            new HttpClientContext());
    newResponse.setEntity(new ByteArrayEntity(entity));
    newResponse.setHeaders(response.getAllHeaders());
    return newResponse;
}
项目:spydroid-ipcamera    文件:TinyHttpServer.java   
protected RequestListener() throws Exception {

            mHttpService = new org.apache.http.protocol.HttpService(
                    mHttpProcessor, 
                    new DefaultConnectionReuseStrategy(), 
                    new DefaultHttpResponseFactory());
            mHttpService.setHandlerResolver(mRegistry);
            mHttpService.setParams(mParams);

        }
项目:ecg_over_rtp    文件:TinyHttpServer.java   
protected RequestListener() throws Exception {

            mHttpService = new org.apache.http.protocol.HttpService(
                    mHttpProcessor, 
                    new DefaultConnectionReuseStrategy(), 
                    new DefaultHttpResponseFactory());
            mHttpService.setHandlerResolver(mRegistry);
            mHttpService.setParams(mParams);

        }
项目: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));
    }
项目: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);
}
项目:illuminati    文件:ESclientImpl.java   
private HttpResponse getHttpResponseByData (final int httpStatus, final String message) {
    HttpResponseFactory factory = new DefaultHttpResponseFactory();
    return factory.newHttpResponse(new BasicStatusLine(this.httpVersion, httpStatus, message), null);
}
项目:PhET    文件:ElementalReverseProxy.java   
public RequestListenerThread(int port, final HttpHost target) throws IOException {
    this.target = target;
    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 HTTP protocol processor for incoming connections
    HttpProcessor inhttpproc = new ImmutableHttpProcessor(
            new HttpRequestInterceptor[] {
                    new RequestContent(),
                    new RequestTargetHost(),
                    new RequestConnControl(),
                    new RequestUserAgent(),
                    new RequestExpectContinue()
     });

    // Set up HTTP protocol processor for outgoing connections
    HttpProcessor outhttpproc = new ImmutableHttpProcessor(
            new HttpResponseInterceptor[] {
                    new ResponseDate(),
                    new ResponseServer(),
                    new ResponseContent(),
                    new ResponseConnControl()
    });

    // Set up outgoing request executor 
    HttpRequestExecutor httpexecutor = new HttpRequestExecutor();

    // Set up incoming request handler
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new ProxyHandler(
            this.target, 
            outhttpproc, 
            httpexecutor));

    // Set up the HTTP service
    this.httpService = new HttpService(
            inhttpproc, 
            new DefaultConnectionReuseStrategy(), 
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
项目:PhET    文件:NHttpFileServer.java   
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.err.println("Please specify document root directory");
        System.exit(1);
    }

    boolean useFileChannels = true;
    if (args.length >= 2) {
        String s = args[1];
        if (s.equalsIgnoreCase("disableFileChannels")) {
            useFileChannels = false;
        }
    }

    HttpParams params = new SyncBasicHttpParams();
    params
        .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20000)
        .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");

    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
            new ResponseDate(),
            new ResponseServer(),
            new ResponseContent(),
            new ResponseConnControl()
    });

    AsyncNHttpServiceHandler handler = new AsyncNHttpServiceHandler(
            httpproc,
            new DefaultHttpResponseFactory(),
            new DefaultConnectionReuseStrategy(),
            params);

    final HttpFileHandler filehandler = new HttpFileHandler(args[0], useFileChannels);

    NHttpRequestHandlerResolver resolver = new NHttpRequestHandlerResolver() {

        public NHttpRequestHandler lookup(String requestURI) {
            return filehandler;
        }

    };

    handler.setHandlerResolver(resolver);

    // Provide an event logger
    handler.setEventListener(new EventLogger());

    IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);
    ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
    try {
        ioReactor.listen(new InetSocketAddress(8080));
        ioReactor.execute(ioEventDispatch);
    } catch (InterruptedIOException ex) {
        System.err.println("Interrupted");
    } catch (IOException e) {
        System.err.println("I/O error: " + e.getMessage());
    }
    System.out.println("Shutdown");
}
项目:PhET    文件:NHttpServer.java   
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.err.println("Please specify document root directory");
        System.exit(1);
    }
    HttpParams params = new SyncBasicHttpParams();
    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");

    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
            new ResponseDate(),
            new ResponseServer(),
            new ResponseContent(),
            new ResponseConnControl()
    });

    BufferingHttpServiceHandler handler = new BufferingHttpServiceHandler(
            httpproc,
            new DefaultHttpResponseFactory(),
            new DefaultConnectionReuseStrategy(),
            params);

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler(args[0]));

    handler.setHandlerResolver(reqistry);

    // Provide an event logger
    handler.setEventListener(new EventLogger());

    IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);
    ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
    try {
        ioReactor.listen(new InetSocketAddress(8080));
        ioReactor.execute(ioEventDispatch);
    } catch (InterruptedIOException ex) {
        System.err.println("Interrupted");
    } catch (IOException e) {
        System.err.println("I/O error: " + e.getMessage());
    }
    System.out.println("Shutdown");
}
项目:PhET    文件:NHttpSSLServer.java   
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.err.println("Please specify document root directory");
        System.exit(1);
    }

    ClassLoader cl = NHttpSSLServer.class.getClassLoader();
    URL url = cl.getResource("test.keystore");
    KeyStore keystore  = KeyStore.getInstance("jks");
    keystore.load(url.openStream(), "nopassword".toCharArray());
    KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
            KeyManagerFactory.getDefaultAlgorithm());
    kmfactory.init(keystore, "nopassword".toCharArray());
    KeyManager[] keymanagers = kmfactory.getKeyManagers(); 
    SSLContext sslcontext = SSLContext.getInstance("TLS");
    sslcontext.init(keymanagers, null, null);

    HttpParams params = new SyncBasicHttpParams();
    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, "Jakarta-HttpComponents-NIO/1.1");

    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
            new ResponseDate(),
            new ResponseServer(),
            new ResponseContent(),
            new ResponseConnControl()
    });

    BufferingHttpServiceHandler handler = new BufferingHttpServiceHandler(
            httpproc,
            new DefaultHttpResponseFactory(),
            new DefaultConnectionReuseStrategy(),
            params);

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler(args[0]));

    handler.setHandlerResolver(reqistry);

    // Provide an event logger
    handler.setEventListener(new EventLogger());

    IOEventDispatch ioEventDispatch = new SSLServerIOEventDispatch(
            handler, 
            sslcontext,
            params);

    ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
    try {
        ioReactor.listen(new InetSocketAddress(8080));
        ioReactor.execute(ioEventDispatch);
    } catch (InterruptedIOException ex) {
        System.err.println("Interrupted");
    } catch (IOException e) {
        System.err.println("I/O error: " + e.getMessage());
    }
    System.out.println("Shutdown");
}
项目:lavaplayer    文件:HttpClientTools.java   
private static ManagedHttpClientConnectionFactory createConnectionFactory() {
  return new ManagedHttpClientConnectionFactory(null, (buffer, constraints) -> {
    return new GarbageAllergicHttpResponseParser(buffer, IcyHttpLineParser.ICY_INSTANCE, DefaultHttpResponseFactory.INSTANCE, constraints);
  });
}
项目:Camel    文件:HttpTestServer.java   
protected HttpResponseFactory newHttpResponseFactory() {
    return new DefaultHttpResponseFactory();
}
项目:FMTech    文件:maj.java   
public final Uri a()
{
  this.a = new ServerSocket();
  this.a.bind(new InetSocketAddress(h, 0));
  long l = System.currentTimeMillis();
  double d1 = Math.random();
  String str1 = 45 + "/" + l + d1;
  String str2 = MimeTypeMap.getFileExtensionFromUrl(this.i.toString());
  if (!TextUtils.isEmpty(str2))
  {
    String str5 = String.valueOf(str1);
    str1 = 1 + String.valueOf(str5).length() + String.valueOf(str2).length() + str5 + "." + str2;
  }
  this.c = new BasicHttpParams().setBooleanParameter("http.connection.stalecheck", false).setBooleanParameter("http.tcp.nodelay", true).setIntParameter("http.socket.buffer-size", 8192);
  BasicHttpProcessor localBasicHttpProcessor = new BasicHttpProcessor();
  localBasicHttpProcessor.addInterceptor(new ResponseContent());
  localBasicHttpProcessor.addInterceptor(new ResponseConnControl());
  HttpRequestHandlerRegistry localHttpRequestHandlerRegistry = new HttpRequestHandlerRegistry();
  String str3;
  FutureTask localFutureTask;
  if (this.i != null)
  {
    str3 = this.i.toString();
    localHttpRequestHandlerRegistry.register(str1, new man(str1, str3, this.j));
    this.d = new HttpService(localBasicHttpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory());
    this.d.setHandlerResolver(localHttpRequestHandlerRegistry);
    this.d.setParams(this.c);
    localFutureTask = new FutureTask(new mak(this));
    if (this.e != null) {
      break label426;
    }
    this.b = Executors.newSingleThreadExecutor();
    this.b.execute(localFutureTask);
  }
  for (;;)
  {
    String str4 = String.valueOf(h.getHostAddress());
    int k = this.a.getLocalPort();
    return Uri.parse(19 + String.valueOf(str4).length() + String.valueOf(str1).length() + "http://" + str4 + ":" + k + str1);
    str3 = null;
    break;
    label426:
    if (this.f != null) {
      this.f.cancel(true);
    }
    this.f = localFutureTask;
    this.e.execute(localFutureTask);
  }
}
项目:CommonCrawlDocumentDownload    文件:ArcRecord.java   
/**
 * <p>Returns an HTTP response object parsed from the ARC record payload.<p>
 * <p>Note: The payload is parsed on-demand, but is only parsed once.  The
 * parsed data is saved for subsequent calls.</p>
 *
 * @return The ARC record payload as an HTTP response object.  See the Apache
 * HttpComponents project.
 */
public HttpResponse getHttpResponse()
    throws IOException, HttpException {

  if (this._httpResponse != null) {
      return this._httpResponse;
  }

  if (this._payload == null) {
    LOG.error("Unable to parse HTTP response: Payload has not been set"); return null;
  }

  if (this._url != null && !this._url.startsWith("http://") && !this._url.startsWith("https://")) {
    LOG.error("Unable to parse HTTP response: URL protocol is not HTTP"); return null;
  }

  this._httpResponse = null;

  // Find where the HTTP headers stop
  int end = this._searchForCRLFCRLF(this._payload);

  if (end == -1) {
    LOG.error("Unable to parse HTTP response: End of HTTP headers not found"); return null;
  }

  // Parse the HTTP status line and headers
  DefaultHttpResponseParser parser =
    new DefaultHttpResponseParser(
      new ByteArraySessionInputBuffer(this._payload, 0, end),
      new BasicLineParser(),
      new DefaultHttpResponseFactory(),
      new BasicHttpParams()
    );

  this._httpResponse = parser.parse();

  if (this._httpResponse == null) {
    LOG.error("Unable to parse HTTP response"); return null;
  }

  // Set the reset of the payload as the HTTP entity.  Use an InputStreamEntity
  // to avoid a memory copy.
  //trim trailing '\n' if it exists
  int entityLength = _payload.length-end;
  if (_payload.length > 0 && _payload[_payload.length-1]=='\n') {
    entityLength--;
  }
  InputStreamEntity entity = new InputStreamEntity(new ByteArrayInputStream(this._payload, end, entityLength), entityLength);
  entity.setContentType(this._httpResponse.getFirstHeader("Content-Type"));
  entity.setContentEncoding(this._httpResponse.getFirstHeader("Content-Encoding"));
  this._httpResponse.setEntity(entity);

  return this._httpResponse;
}
项目:openxds    文件:IheHttpFactory.java   
public HttpResponseFactory newResponseFactory() {
    return new DefaultHttpResponseFactory();
}