public String getRedHost() { try { final URIBuilder uriBuilder =new URIBuilder(getRedSchmemHost()); return uriBuilder.getHost(); } catch (URISyntaxException e) { LOGGER.error(ERROR,e); } return null; }
protected HttpUriRequest getHttpRequest(String[] urls, String path, List<NameValuePair> queryParams, int urlIndex, String httpMethod, boolean requiresNewAuth) throws URISyntaxException, IOException { URIBuilder uriBuilder = null; uriBuilder = new URIBuilder(urls[urlIndex]).setPath(path).setParameters(queryParams); if (uriBuilder.getHost().equals("localhost")) { uriBuilder.setHost(InetAddress.getLocalHost().getCanonicalHostName()); } HttpUriRequest httpUriRequest = null; switch (httpMethod) { case HttpPut.METHOD_NAME: httpUriRequest = new HttpPut(uriBuilder.build()); break; case HttpPost.METHOD_NAME: httpUriRequest = new HttpPost(uriBuilder.build()); break; default: httpUriRequest = new HttpGet(uriBuilder.build()); break; } return httpUriRequest; }
public String getRedSchmemHost() { final DifferPress differPress = getDependAccountResult(DifferPress.class); if (null == differPress) { throw new CloudDiskException(MsgConst.HOST_VALUE_NOT_NULL); } else { final URIBuilder uri = differPress.getRedirectUrl(); return new StringBuilder(uri.getScheme()).append("://").append(uri.getHost()).toString(); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * Provides information from the server URL. * * @param urlInfo * the url info * @return the string */ @Override public String findURLInformation(final URL_INFORMATION urlInfo) { String returnString = null; try { final URIBuilder builder = new URIBuilder(serverURL); if (urlInfo == URL_INFORMATION.HOST) { returnString = builder.getHost(); } else if (urlInfo == URL_INFORMATION.PORT) { returnString = Integer.toString(builder.getPort()); } else if (urlInfo == URL_INFORMATION.PROTOCOL) { returnString = builder.getScheme(); } } catch (final Exception e) { log.warn("Unable to determine host name for: " + serverURL, e); } return returnString; }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ENGLISH)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ENGLISH)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
private JsonObject sendPost(URIBuilder target, JsonElement payload) { try { if (!target.getScheme().equals("matrix")) { throw new IllegalArgumentException("Scheme can only be matrix"); } String domain = target.getHost(); target.setScheme("https"); IRemoteAddress addr = resolver.resolve(target.getHost()); target.setHost(addr.getHost()); target.setPort(addr.getPort()); return sendPost(domain, target.build(), payload); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
private JsonObject sendPut(URIBuilder target, JsonElement payload) { try { if (!target.getScheme().equals("matrix")) { throw new IllegalArgumentException("Scheme can only be matrix"); } String domain = target.getHost(); target.setScheme("https"); IRemoteAddress addr = resolver.resolve(target.getHost()); target.setHost(addr.getHost()); target.setPort(addr.getPort()); return sendPut(domain, target.build(), payload); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
private JsonObject sendGet(URIBuilder target) { try { if (!target.getScheme().equals("matrix")) { throw new IllegalArgumentException("Scheme can only be matrix"); } String domain = target.getHost(); target.setScheme("https"); IRemoteAddress addr = resolver.resolve(target.getHost()); target.setHost(addr.getHost()); target.setPort(addr.getPort()); return sendGet(domain, target.build()); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT)); } uribuilder.setFragment(null); return uribuilder.build(); }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT)); } uribuilder.setFragment(null); return uribuilder.build(); }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH)); } uribuilder.setFragment(null); return uribuilder.build(); }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT)); } uribuilder.setFragment(null); return uribuilder.build(); }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT)); } uribuilder.setFragment(null); return uribuilder.build(); }
@Override protected void buildCookie(com.intuit.karate.http.Cookie c) { BasicClientCookie cookie = new BasicClientCookie(c.getName(), c.getValue()); for (Entry<String, String> entry : c.entrySet()) { switch (entry.getKey()) { case DOMAIN: cookie.setDomain(entry.getValue()); break; case PATH: cookie.setPath(entry.getValue()); break; } } if (cookie.getDomain() == null) { cookie.setDomain(uriBuilder.getHost()); } cookieStore.addCookie(cookie); }