protected HttpEndpoint createHttpEndpoint(String uri, HttpComponent component, HttpClientParams clientParams, HttpConnectionManager connectionManager, HttpClientConfigurer configurer) throws URISyntaxException { return new HttpEndpoint(uri, component, clientParams, connectionManager, configurer); }
public PollingConsumer createPollingConsumer() throws Exception { HttpPollingConsumer answer = new HttpPollingConsumer(this); configurePollingConsumer(answer); return answer; }
public HttpProducer(HttpEndpoint endpoint) { super(endpoint); this.httpClient = endpoint.createHttpClient(); this.throwException = endpoint.isThrowExceptionOnFailure(); this.transferException = endpoint.isTransferException(); }
ObjectHelper.notNull(httpConnectionManager, "httpConnectionManager"); HttpClient answer = new HttpClient(getClientParams()); if (ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyHost")) && ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyPort"))) { String host = getCamelContext().getProperty("http.proxyHost"); int port = Integer.parseInt(getCamelContext().getProperty("http.proxyPort")); LOG.debug("CamelContext properties http.proxyHost and http.proxyPort detected. Using http proxy host: {} port: {}", host, port); answer.getHostConfiguration().setProxy(host, port); if (getProxyHost() != null) { LOG.debug("Using proxy: {}:{}", getProxyHost(), getProxyPort()); answer.getHostConfiguration().setProxy(getProxyHost(), getProxyPort()); if (getAuthMethodPriority() != null) { List<String> authPrefs = new ArrayList<>(); Iterator<?> it = getCamelContext().getTypeConverter().convertTo(Iterator.class, getAuthMethodPriority()); int i = 1; while (it.hasNext()) { Object value = it.next(); AuthMethod auth = getCamelContext().getTypeConverter().convertTo(AuthMethod.class, value); if (auth == null) { throw new IllegalArgumentException("Unknown authMethod: " + value + " in authMethodPriority: " + getAuthMethodPriority()); HttpClientConfigurer configurer = getHttpClientConfigurer(); if (configurer != null) { configurer.configureHttpClient(answer);
if (getEndpoint().isBridgeEndpoint()) { exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE); String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy(); if (getEndpoint().getCookieHandler() != null) { Map<String, List<String>> cookieHeaders = getEndpoint().getCookieHandler().loadCookies(exchange, new URI(method.getURI().getEscapedURI())); for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) { String key = entry.getKey(); if (getEndpoint().isConnectionClose()) { method.addRequestHeader("Connection", "close"); boolean ok = HttpHelper.isStatusCodeOk(responseCode, getEndpoint().getOkStatusCodeRange()); if (ok) {
protected void populateResponse(Exchange exchange, HttpMethod method, Message in, HeaderFilterStrategy strategy, int responseCode) throws IOException, ClassNotFoundException, URISyntaxException { Object response = extractResponseBody(method, exchange, getEndpoint().isIgnoreResponseBody()); Message answer = exchange.getOut(); if (getEndpoint().getCookieHandler() != null) { getEndpoint().getCookieHandler().storeCookies(exchange, new URI(method.getURI().getEscapedURI()), m); if (getEndpoint().isCopyHeaders()) { MessageHelper.copyHeaders(exchange.getIn(), answer, httpProtocolHeaderFilterStrategy, false);
if (getEndpoint().getComponent().isAllowJavaSerializedObject() || getEndpoint().isTransferException()) { return HttpHelper.deserializeJavaObjectFromStream(is, exchange.getContext()); } else { if (!getEndpoint().isDisableStreamCache()) {
protected Exchange doReceive(int timeout) { Exchange exchange = endpoint.createExchange(); HttpMethod method = createMethod(exchange); HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy(); for (Header header : headers) { String name = header.getName();
Map<String, String> headers = extractResponseHeaders(method.getResponseHeaders()); if (getEndpoint().getCookieHandler() != null) { Map<String, List<String>> m = new HashMap<>(); for (Entry<String, String> e : headers.entrySet()) { m.put(e.getKey(), Collections.singletonList(e.getValue())); getEndpoint().getCookieHandler().storeCookies(exchange, new URI(method.getURI().getEscapedURI()), m); Object responseBody = extractResponseBody(method, exchange, getEndpoint().isIgnoreResponseBody()); if (transferException && responseBody instanceof Exception) {
endpoint.setHeaderFilterStrategy(new HttpRestHeaderFilterStrategy(path, queryParameters)); return endpoint.createProducer();
public HttpPollingConsumer(HttpEndpoint endpoint) { super(endpoint); this.endpoint = endpoint; this.httpClient = endpoint.createHttpClient(); }
if (!getEndpoint().getComponent().isAllowJavaSerializedObject()) { throw new CamelExchangeException("Content-type " + HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT + " is not allowed", exchange);