@Override public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { HttpAsyncClient asyncClient = getHttpAsyncClient(); startAsyncClient(); HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri); postProcessHttpRequest(httpRequest); HttpContext context = createHttpContext(httpMethod, uri); if (context == null) { context = HttpClientContext.create(); } // Request configuration not set in the context if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) { // Use request configuration given by the user, when available RequestConfig config = null; if (httpRequest instanceof Configurable) { config = ((Configurable) httpRequest).getConfig(); } if (config == null) { config = RequestConfig.DEFAULT; } context.setAttribute(HttpClientContext.REQUEST_CONFIG, config); } return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context); }
@Override public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { HttpAsyncClient asyncClient = getHttpAsyncClient(); startAsyncClient(); HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri); postProcessHttpRequest(httpRequest); HttpContext context = createHttpContext(httpMethod, uri); if (context == null) { context = HttpClientContext.create(); } // Request configuration not set in the context if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) { // Use request configuration given by the user, when available RequestConfig config = null; if (httpRequest instanceof Configurable) { config = ((Configurable) httpRequest).getConfig(); } if (config == null) { config = createRequestConfig(asyncClient); } if (config != null) { context.setAttribute(HttpClientContext.REQUEST_CONFIG, config); } } return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context); }
protected AbstractRemoteOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull OD operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset, final int okStatusCode) { this.host = host; this.httpClient = httpClient; this.resourceName = resourceName; this.operationDeclaration = operationDeclaration; this.serverProtocol = serverProtocol; this.charset = charset; this.okStatusCode = okStatusCode; }
public RemoteCustomOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull CustomOperationDeclaration operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset) { super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK); }
public RemoteReadOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull ReadOperationDeclaration operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset) { super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK); }
public RemoteUpdateOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull UpdateOperationDeclaration operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset) { super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK); }
public RemoteDeleteOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull DeleteOperationDeclaration operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset) { super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK); }
public RemoteCreateOperationInvocation( final @NotNull HttpHost host, final @NotNull HttpAsyncClient httpClient, final @NotNull String resourceName, final @NotNull CreateOperationDeclaration operationDeclaration, final @NotNull ServerProtocol serverProtocol, final @NotNull Charset charset) { super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.CREATED); }
@Override public void run() { // To change body of implemented methods use File | Settings | File Templates.if (log.isDebugEnabled()) log.debug("URI=[{}] 의 웹 컨텐츠를 비동기 방식으로 다운로드 받아 캐시합니다.", url); try { String responseStr; HttpAsyncClient httpClient = new DefaultHttpAsyncClient(); httpClient.start(); HttpGet request = new HttpGet(url); Future<HttpResponse> future = httpClient.execute(request, null); HttpResponse response = future.get(); responseStr = EntityUtils.toString(response.getEntity(), Charsets.UTF_8.toString()); httpClient.shutdown(); if (log.isDebugEnabled()) log.debug("URI=[{}]로부터 웹 컨텐츠를 다운로드 받았습니다. responseStr=[{}]", url, StringTool.ellipsisChar(responseStr, 255)); ctx.getResponse().setCharacterEncoding("UTF-8"); PrintWriter writer = ctx.getResponse().getWriter(); writer.write(responseStr); writer.close(); ctx.complete(); } catch (Exception ignored) { throw new RuntimeException(ignored); } }
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) { this.httpClient = httpClient; this.httpRequest = httpRequest; this.httpContext = httpContext; }
protected HttpAsyncClient getProxyClientAsync() { return httpClient; }
public DefaultClient(HttpAsyncClient client, ClientConfig config) { this.client = client; this.config = config; }
public HttpAsyncClient getClient() { return client; }
public HttpAsyncClient http() { return clnt; }
public AbstractClient(String baseUri, HttpAsyncClient httpClient) throws URISyntaxException { this(new URI(baseUri), httpClient); }
public AbstractClient(URI baseUri, HttpAsyncClient httpClient) { this.baseUri = baseUri; this.httpClient = httpClient; }
public Consumer(String consumers, HttpAsyncClient httpClient) throws URISyntaxException { super(consumers, httpClient); }
public Consumer(URI consumers, HttpAsyncClient httpClient) { super(consumers, httpClient); }
public Producer(String topics, HttpAsyncClient httpClient) throws URISyntaxException { super(topics, httpClient); }
public Producer(URI topics, HttpAsyncClient httpClient) { super(topics, httpClient); }
@Autowired public HystrixMonitor(HttpAsyncClient httpAsyncClient, MonitoringSystem monitoringSystem) { this.httpAsyncClient = httpAsyncClient; this.monitoringSystem = monitoringSystem; }
@Override public Future<HttpResponse> execute(final HttpAsyncClient httpClient) throws FileNotFoundException { final HttpAsyncResponseConsumer<HttpResponse> consumer = new BasicAsyncResponseConsumer(); final HttpAsyncRequestProducer producer = this.getProducer(); return httpClient.execute(producer, consumer, null); }
@Override public Future<HttpResponse> execute(final HttpAsyncClient httpClient) { final HttpUriRequest request = this.createRequest(); return httpClient.execute(request, null); }
Future<HttpResponse> execute(HttpAsyncClient httpClient) throws IOException;