@Override public ApacheHttpResponseHandler createResponseHandler(Config config) { return new ApacheHttpResponseHandler(); }
@Override public ApacheHttpResponseStatus handleResponse(Request<HttpUriRequest> request, RP response) { ApacheHttpResponseStatus status = new ApacheHttpResponseStatus(StatusType.OK); int statusCode = response.getStatusLine().getStatusCode(); status.setStatusCode(statusCode); HttpUtils.updateStatusType(status, statusCode, errorCodeWhitelist); if (status.getType() == StatusType.OK) { status.setContent(getEntityAsByteArray(response.getEntity())); status.setContentType(response.getEntity().getContentType().getValue()); } else { log.info("Receive an unsuccessful response with status code: " + statusCode); } HttpEntity entity = response.getEntity(); if (entity != null) { consumeEntity(entity); } return status; }
@Override public ApacheHttpResponseStatus handleResponse(Request<HttpUriRequest> request, RP response) { ApacheHttpResponseStatus status = new ApacheHttpResponseStatus(StatusType.OK); int statusCode = response.getStatusLine().getStatusCode(); status.setStatusCode(statusCode); HttpUtils.updateStatusType(status, statusCode, errorCodeWhitelist); if (status.getType() == StatusType.OK) { status.setContent(getEntityAsByteArray(response.getEntity())); status.setContentType(response.getEntity().getContentType().getValue()); } else { log.info("Receive an unsuccessful response with status code: " + statusCode); } HttpEntity entity = response.getEntity(); if (entity != null) { consumeEntity(entity); } return status; }
@Override public AvroHttpWriterBuilder fromConfig(Config config) { config = config.withFallback(FALLBACK); ApacheHttpClient client = new ApacheHttpClient(HttpClientBuilder.create(), config, broker); this.client = client; String urlTemplate = config.getString(HttpConstants.URL_TEMPLATE); String verb = config.getString(HttpConstants.VERB); String contentType = config.getString(HttpConstants.CONTENT_TYPE); this.asyncRequestBuilder = new ApacheHttpRequestBuilder(urlTemplate, verb, contentType); Set<String> errorCodeWhitelist = HttpUtils.getErrorCodeWhitelist(config); this.responseHandler = new ApacheHttpResponseHandler(errorCodeWhitelist); return this; } }
@Override public ApacheHttpResponseHandler createResponseHandler(Config config) { return new ApacheHttpResponseHandler(); }
@Override public AvroHttpWriterBuilder fromConfig(Config config) { config = config.withFallback(FALLBACK); ApacheHttpClient client = new ApacheHttpClient(HttpClientBuilder.create(), config, broker); this.client = client; String urlTemplate = config.getString(HttpConstants.URL_TEMPLATE); String verb = config.getString(HttpConstants.VERB); String contentType = config.getString(HttpConstants.CONTENT_TYPE); this.asyncRequestBuilder = new ApacheHttpRequestBuilder(urlTemplate, verb, contentType); Set<String> errorCodeWhitelist = HttpUtils.getErrorCodeWhitelist(config); this.responseHandler = new ApacheHttpResponseHandler(errorCodeWhitelist); return this; } }