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


Java HttpProcessor類代碼示例

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


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

示例1: execute

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
public HttpResponse execute(HttpRequest request) throws IOException, HttpException {
  HttpParams params = new BasicHttpParams();
  HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);

  HttpProcessor processor = new ImmutableHttpProcessor(new RequestContent());

  HttpRequestExecutor executor = new HttpRequestExecutor();

  HttpContext context = new BasicHttpContext(null);
  context.setAttribute(ExecutionContext.HTTP_CONNECTION, connection);

  if (!connection.isOpen()) {
    Socket socket = new Socket(address.getAddress(), address.getPort());
    connection.bind(socket, params);
  }

  context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
  request.setParams(params);
  executor.preProcess(request, processor, context);
  HttpResponse response = executor.execute(request, connection, context);
  executor.postProcess(response, processor, context);

  return response;
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:25,代碼來源:RequestExecutorBasedClientInstrumentationTest.java

示例2: DefaultRequestDirector

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:DefaultRequestDirector.java

示例3: createMainExec

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
/**
 * Produces an instance of {@link ClientExecChain} to be used as a main exec.
 * <p>
 * Default implementation produces an instance of {@link MainClientExec}
 * </p>
 * <p>
 * For internal use.
 * </p>
 *
 * @since 4.4
 */
protected ClientExecChain createMainExec(
        final HttpRequestExecutor requestExec,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy,
        final HttpProcessor proxyHttpProcessor,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler)
{
    return new MainClientExec(
            requestExec,
            connManager,
            reuseStrategy,
            keepAliveStrategy,
            proxyHttpProcessor,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler);
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:32,代碼來源:HttpClientBuilder.java

示例4: RequestListenerThread

import org.apache.http.protocol.HttpProcessor; //導入依賴的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

示例5: LocalTestServer

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
public LocalTestServer(HttpRequestHandler handler) {
    try {
        setUp();
        HttpProcessor httpproc = HttpProcessorBuilder.create()
            .add(new ResponseDate())
            .add(new ResponseServer(LocalServerTestBase.ORIGIN))
            .add(new ResponseContent())
            .add(new ResponseConnControl())
            .add(new RequestBasicAuth())
            .add(new ResponseBasicUnauthorized()).build();
        this.serverBootstrap.setHttpProcessor(httpproc);
        this.serverBootstrap.registerHandler("*", handler);
        host = start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:yahoo,項目名稱:gondola,代碼行數:18,代碼來源:LocalTestServer.java

示例6: getHttpProcessor

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
private HttpProcessor getHttpProcessor() {
  if (null == _httpProcessor) {
    final HttpProcessorBuilder httpProcessorBuilder = HttpProcessorBuilder.create();

    httpProcessorBuilder.add(new ResponseDate());
    httpProcessorBuilder.add(new ResponseServer(getOriginServer()));
    httpProcessorBuilder.add(new ResponseContent());
    httpProcessorBuilder.add(new ResponseConnControl());
    httpProcessorBuilder.add(getRequestInterceptorService());
    httpProcessorBuilder.add(getResponseInterceptorService());

    _httpProcessor = httpProcessorBuilder.build();
  }

  return _httpProcessor;
}
 
開發者ID:Sabadios,項目名稱:Cherry,代碼行數:17,代碼來源:WebEngine.java

示例7: start

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
public void start() throws Exception {
	// Create HTTP protocol basic processing chain
	HttpProcessor httpProcessor = HttpProcessorBuilder.create()
			.add(new ResponseDate()).add(new ResponseContent())
			.add(new ResponseConnControl()).build();
	// Create server
	HttpAsyncService protocolHandler = new HttpAsyncService(httpProcessor,
			uriMapper);
	NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory = new DefaultNHttpServerConnectionFactory();
	IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(
			protocolHandler, connFactory);
	IOReactorConfig config = IOReactorConfig.custom()
			.setIoThreadCount(threads).setSoReuseAddress(true).build();
	ListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
	// Start server
	ioReactor.listen(new InetSocketAddress(port));
	ioReactor.execute(ioEventDispatch);
}
 
開發者ID:fxbonnet,項目名稱:nio-benchmark,代碼行數:19,代碼來源:AsyncServer.java

示例8: getRequestDirector

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
 
開發者ID:triveous,項目名稱:SoundcloudAPI,代碼行數:19,代碼來源:ApiWrapper.java

示例9: AxisHttpRequestImpl

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
public AxisHttpRequestImpl(
        final AxisHttpConnection conn,
        final HttpRequest request, 
        final HttpProcessor httpproc,
        final HttpContext context) {
    super();
    if (conn == null) {
        throw new IllegalArgumentException("HTTP connection may not be null");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (httpproc == null) {
        throw new IllegalArgumentException("HTTP processor may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }
    this.request = request;
    this.conn = conn;
    this.httpproc = httpproc;
    this.context = context;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:AxisHttpRequestImpl.java

示例10: AxisHttpResponseImpl

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
public AxisHttpResponseImpl(
        final AxisHttpConnection conn,
        final HttpResponse response, 
        final HttpProcessor httpproc,
        final HttpContext context) {
    super();
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    if (conn == null) {
        throw new IllegalArgumentException("HTTP connection may not be null");
    }
    if (httpproc == null) {
        throw new IllegalArgumentException("HTTP processor may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }
    this.response = response;
    this.conn = conn;
    this.httpproc = httpproc;
    this.context = context;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:AxisHttpResponseImpl.java

示例11: getRequestDirector

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
	return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
			httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
			stateHandler, params);
}
 
開發者ID:EnteriseToolkit,項目名稱:paperchains,代碼行數:19,代碼來源:ApiWrapper.java

示例12: main

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
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();
}
 
開發者ID:haogrgr,項目名稱:haogrgr-test,代碼行數:21,代碼來源:HttpSrvMain.java

示例13: RequestListenerThread

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:pmeisen,項目名稱:gen-server-http-listener,代碼行數:35,代碼來源:RequestListenerThread.java

示例14: RequestListenerThread

import org.apache.http.protocol.HttpProcessor; //導入依賴的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

示例15: createClientRequestDirector

import org.apache.http.protocol.HttpProcessor; //導入依賴的package包/類
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:AbstractHttpClient.java


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