19 package org.turro.http;
21 import java.net.MalformedURLException;
23 import java.net.URISyntaxException;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.turro.string.Strings;
28 import org.apache.hc.core5.net.URIBuilder;
29 import org.turro.elephant.context.ElephantContext;
39 URIBuilder url =
new URIBuilder(server);
40 if(url.getScheme() ==
null) {
41 if(secured) url.setScheme(
"https");
else url.setScheme(
"http");
43 if(url.getHost() ==
null) {
47 url.setPath(
"/" + path[1]);
53 if(path !=
null && path.length > 0) {
54 url.setPath(
"/" + path[0]);
60 return url.build().toString();
61 }
catch (URISyntaxException ex) {
68 if(!Strings.isBlank(path)) {
69 path = path.replaceFirst(
"^[\\/ ]+",
"");
70 path = path.replaceFirst(
"[\\/ ]+$",
"");
71 return path.split(
"\\/");
77 public static String
absolute(String appServer, String path)
throws URISyntaxException, MalformedURLException {
78 URI url =
new URI(path);
79 if(url.isAbsolute()) {
82 return new URL(
new URL(appServer), path).toString();
static String logMsg(String msg)
static String absolute(String appServer, String path)
static String[] splitPath(String path)
static String checkAppServer(String server, boolean secured)