當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultHttpResponseFactory類代碼示例

本文整理匯總了Java中org.apache.http.impl.DefaultHttpResponseFactory的典型用法代碼示例。如果您正苦於以下問題:Java DefaultHttpResponseFactory類的具體用法?Java DefaultHttpResponseFactory怎麽用?Java DefaultHttpResponseFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultHttpResponseFactory類屬於org.apache.http.impl包,在下文中一共展示了DefaultHttpResponseFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: QSystemHtmlInstance

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:25,代碼來源:QSystemHtmlInstance.java

示例2: RequestListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);

}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:19,代碼來源:YaaccUpnpServerService.java

示例3: RequestListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:Torridity,項目名稱:dsworkbench,代碼行數:26,代碼來源:ReportServer.java

示例4: HttpServerConnectionUpnpStream

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:25,代碼來源:HttpServerConnectionUpnpStream.java

示例5: ListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:jasoncn90,項目名稱:dlna-for-android,代碼行數:18,代碼來源:HttpServer.java

示例6: handleResponseTest

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
/**
 * 
 */
@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());
}
 
開發者ID:conwetlab,項目名稱:fiware-rss,代碼行數:22,代碼來源:ResponseHandlerTest.java

示例7: put

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
    }
}
 
開發者ID:bintray,項目名稱:bintray-client-java,代碼行數:27,代碼來源:BintrayImpl.java

示例8: RequestListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:YinYanfei,項目名稱:CadalWorkspace,代碼行數:20,代碼來源:Httpd.java

示例9: RequestListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:31,代碼來源:ElementalHttpServer.java

示例10: ListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:32,代碼來源:ApiServer.java

示例11: ListenerThread

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:34,代碼來源:ClusterServiceServletContainer.java

示例12: sendAndReturn

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
@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);
}
 
開發者ID:JasonBian,項目名稱:azkaban,代碼行數:31,代碼來源:RestfulApiClientTest.java

示例13: setNextHttpResponse

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
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);
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:9,代碼來源:CoredumpHandlerTest.java

示例14: RequestListener

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
protected RequestListener() throws Exception {

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

		}
 
開發者ID:ghazi94,項目名稱:Android_CCTV,代碼行數:11,代碼來源:TinyHttpServer.java

示例15: DefaultHttpResponseParserFactory

import org.apache.http.impl.DefaultHttpResponseFactory; //導入依賴的package包/類
public DefaultHttpResponseParserFactory(
        final LineParser lineParser,
        final HttpResponseFactory responseFactory) {
    super();
    this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
    this.responseFactory = responseFactory != null ? responseFactory
            : DefaultHttpResponseFactory.INSTANCE;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:9,代碼來源:DefaultHttpResponseParserFactory.java


注:本文中的org.apache.http.impl.DefaultHttpResponseFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。