本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}