/** * The service publish address. */ public void setAddress(String address) { super.setEndpointUri(UnsafeUriCharactersEncoder.encodeHttpURI(address)); this.address = address; }
private static String pathAsKey(String path) { // cater for default path if (path == null || path.equals("/")) { path = ""; } // strip out query parameters int idx = path.indexOf('?'); if (idx > -1) { path = path.substring(0, idx); } // strip of ending / if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } return UnsafeUriCharactersEncoder.encodeHttpURI(path); }
public static URI makeHttpURI(String httpURI) { return makeHttpURI( URI.create(UnsafeUriCharactersEncoder.encodeHttpURI(httpURI)) ); }
protected void updateEndpointUri(String endpointUri) { super.setEndpointUri(UnsafeUriCharactersEncoder.encodeHttpURI(endpointUri)); }
private StatusLine sendRoomMessage(String room, Exchange exchange) throws IOException, InvalidPayloadException { String urlPath = String.format(getConfig().withAuthToken(HipchatApiConstants.URI_PATH_ROOM_NOTIFY), room); String backGroundColor = exchange.getIn().getHeader(HipchatConstants.MESSAGE_BACKGROUND_COLOR, String.class); Map<String, String> jsonParam = getCommonHttpPostParam(exchange); if (backGroundColor != null) { jsonParam.put(HipchatApiConstants.API_MESSAGE_COLOR, backGroundColor); } LOG.info("Sending message to room: " + room + ", " + MAPPER.writeValueAsString(jsonParam)); StatusLine statusLine = post(encodeHttpURI(urlPath), jsonParam); LOG.debug("Response status for send room message: {}", statusLine); return statusLine; }
private URI getHttpUri(Map<String, Object> parameters) { URI uri = null; // check if a client has been supplied to the parameters map for (Object value : parameters.values()) { if (value instanceof URI) { uri = URI.class.cast(value); break; } } if (ObjectHelper.isEmpty(uri)) { String httpUri = (String)parameters.get("httpURI"); if (!ObjectHelper.isEmpty(httpUri)) { uri = URI.create(UnsafeUriCharactersEncoder.encodeHttpURI(httpUri)); } } return uri; }
/** * 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 URL getRequestUrl(GHttpEndpoint endpoint, Exchange exchange) throws Exception { String uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class); String query = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); if (uri != null && !endpoint.isBridgeEndpoint()) { return getEndpointUrl(UnsafeUriCharactersEncoder.encodeHttpURI(uri), query); } return getEndpointUrl(endpoint.getEndpointUri(), query); }
/** * 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; }
queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString); uri = URISupport.createURIWithQuery(uri, queryString);
@Override protected NettyConfiguration parseConfiguration(NettyConfiguration configuration, String remaining, Map<String, Object> parameters) throws Exception { // ensure uri is encoded to be valid String safe = UnsafeUriCharactersEncoder.encodeHttpURI(remaining); URI uri = new URI(safe); configuration.parseURI(uri, parameters, this, "http", "https"); // force using tcp as the underlying transport configuration.setProtocol("tcp"); configuration.setTextline(false); if (configuration instanceof NettyHttpConfiguration) { ((NettyHttpConfiguration) configuration).setPath(uri.getPath()); } return configuration; }
uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
uriString = UnsafeUriCharactersEncoder.encodeHttpURI(uriString); URI uri = new URI(uriString); queryString = uri.getQuery();
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { URI uriHttpUriAddress = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining)); URI endpointUri = URISupport.createRemainingURI(uriHttpUriAddress, parameters);
addressUri = UnsafeUriCharactersEncoder.encodeHttpURI(addressUri); URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), httpClientParameters);
URI u = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining));
URI httpUri = URISupport.createRemainingURI(new URI(UnsafeUriCharactersEncoder.encodeHttpURI(uri)), parameters);