/** * Creates the URI to invoke. * * @param exchange the exchange * @param url the url to invoke * @param endpoint the endpoint * @return the URI to invoke */ public static URI createURI(Exchange exchange, String url, NettyHttpEndpoint endpoint) throws URISyntaxException { URI uri = new URI(url); // is a query string provided in the endpoint URI or in a header // (header overrules endpoint, raw query header overrules query header) String queryString = exchange.getIn().getHeader(Exchange.HTTP_RAW_QUERY, String.class); if (queryString == null) { queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); } if (queryString == null) { // use raw as we encode just below queryString = uri.getRawQuery(); } if (queryString != null) { // need to encode query string queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString); uri = URISupport.createURIWithQuery(uri, queryString); } return uri; }
protected URI prepareCamelUri(String schema, String path, Map<String, Object> params) throws URISyntaxException { String url; if (schema == null) { url = path; } else { url = schema + "://" + path; } URI camelUri; try { camelUri = new URI(URISupport.normalizeUri(url)); } catch (UnsupportedEncodingException e) { camelUri = new URI(url); } if (params.isEmpty()) { return camelUri; } else { return URISupport.createURIWithQuery(camelUri, URISupport.createQueryString(params)); } }
protected URI prepareCamelUri(String schema, String path, Map<String, Object> params) throws URISyntaxException { String url; if (schema == null) { url = path; } else { url = schema + "://" + path; } URI camelUri; try { camelUri = new URI(URISupport.normalizeUri(url)); } catch (UnsupportedEncodingException e) { camelUri = new URI(url); } if (params.isEmpty()) { return camelUri; } else { return URISupport.createURIWithQuery(camelUri, URISupport.createQueryString(params)); } } }
uri = URISupport.createURIWithQuery(uri, queryString);
/** * Creates the URI to invoke. * * @param exchange the exchange * @param url the url to invoke * @param endpoint the endpoint * @return the URI to invoke */ public static URI createURI(Exchange exchange, String url, UndertowEndpoint endpoint) throws URISyntaxException { URI uri = new URI(url); // rest producer may provide an override query string to be used which we should discard if using (hence the remove) String queryString = (String) exchange.getIn().removeHeader(Exchange.REST_HTTP_QUERY); // is a query string provided in the endpoint URI or in a header (header overrules endpoint) if (queryString == null) { queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); } if (queryString == null) { queryString = endpoint.getHttpURI().getRawQuery(); } // We should user the query string from the HTTP_URI header if (queryString == null) { queryString = uri.getRawQuery(); } if (queryString != null) { // need to encode query string queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString); uri = URISupport.createURIWithQuery(uri, queryString); } return uri; }