/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Jenkins.getInstance().getRootUrl(); if(rootUrl !=null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. return rootUrl; StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if(! (req.getScheme().equals("http") && req.getLocalPort()==80 || req.getScheme().equals("https") && req.getLocalPort()==443)) buf.append(':').append(req.getLocalPort()); buf.append(req.getContextPath()).append('/'); return buf.toString(); }
String scheme = getXForwardedHeader(req, "X-Forwarded-Proto", req.getScheme()); buf.append(scheme).append("://"); String host = getXForwardedHeader(req, "X-Forwarded-Host", req.getServerName());
public String getFullUrl() { StringBuilder buf = new StringBuilder(); StaplerRequest req = Stapler.getCurrentRequest(); buf.append(req.getScheme()); buf.append("://"); buf.append(req.getServerName()); if(req.getServerPort()!=80) buf.append(':').append(req.getServerPort()); buf.append(getUrl()); return buf.toString(); }
public String getFullUrl() { StringBuilder buf = new StringBuilder(); StaplerRequest req = Stapler.getCurrentRequest(); buf.append(req.getScheme()); buf.append("://"); buf.append(req.getServerName()); if(req.getServerPort()!=80) buf.append(':').append(req.getServerPort()); buf.append(getUrl()); return buf.toString(); }
public String getFullUrl() { StringBuilder buf = new StringBuilder(); StaplerRequest req = Stapler.getCurrentRequest(); buf.append(req.getScheme()); buf.append("://"); buf.append(req.getServerName()); if(req.getServerPort()!=80) buf.append(':').append(req.getServerPort()); buf.append(getUrl()); return buf.toString(); }
/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Jenkins.getInstance().getRootUrl(); if(rootUrl !=null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. return rootUrl; StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if(! (req.getScheme().equals("http") && req.getLocalPort()==80 || req.getScheme().equals("https") && req.getLocalPort()==443)) buf.append(':').append(req.getLocalPort()); buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Hudson.getInstance().getRootUrl(); if(rootUrl !=null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. return rootUrl; StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if(req.getLocalPort()!=80) buf.append(':').append(req.getLocalPort()); buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Hudson.getInstance().getRootUrl(); if (rootUrl != null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. { return rootUrl; } StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if (req.getLocalPort() != 80) { buf.append(':').append(req.getLocalPort()); } buf.append(getRequestRootPath(req)).append('/'); return buf.toString(); }
/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Hudson.getInstance().getRootUrl(); if(rootUrl !=null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. return rootUrl; StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if(req.getLocalPort()!=80) buf.append(':').append(req.getLocalPort()); buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Infers the hudson installation URL from the given request. */ public static String inferHudsonURL(StaplerRequest req) { String rootUrl = Hudson.getInstance().getRootUrl(); if(rootUrl !=null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc. return rootUrl; StringBuilder buf = new StringBuilder(); buf.append(req.getScheme()).append("://"); buf.append(req.getServerName()); if(req.getLocalPort()!=80) buf.append(':').append(req.getLocalPort()); buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Gets the absolute URL of Hudson top page, such as "http://localhost/hudson/". * * <p> * Unlike {@link #getRootUrl()}, which uses the manually configured value, * this one uses the current request to reconstruct the URL. The benefit is * that this is immune to the configuration mistake (users often fail to set the root URL * correctly, especially when a migration is involved), but the downside * is that unless you are processing a request, this method doesn't work. * * @since 1.263 */ public String getRootUrlFromRequest() { StaplerRequest req = Stapler.getCurrentRequest(); StringBuilder buf = new StringBuilder(); buf.append(req.getScheme() + "://"); buf.append(req.getServerName()); if (req.getServerPort() != 80) { buf.append(':').append(req.getServerPort()); } buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Gets the absolute URL of Hudson top page, such as "http://localhost/hudson/". * * <p> * Unlike {@link #getRootUrl()}, which uses the manually configured value, * this one uses the current request to reconstruct the URL. The benefit is * that this is immune to the configuration mistake (users often fail to set the root URL * correctly, especially when a migration is involved), but the downside * is that unless you are processing a request, this method doesn't work. * * @since 1.263 */ public String getRootUrlFromRequest() { StaplerRequest req = Stapler.getCurrentRequest(); StringBuilder buf = new StringBuilder(); buf.append(req.getScheme() + "://"); buf.append(req.getServerName()); if (req.getServerPort() != 80) { buf.append(':').append(req.getServerPort()); } buf.append(req.getContextPath()).append('/'); return buf.toString(); }
/** * Gets the absolute URL of Hudson top page, such as "http://localhost/hudson/". * * <p> * Unlike {@link #getRootUrl()}, which uses the manually configured value, * this one uses the current request to reconstruct the URL. The benefit is * that this is immune to the configuration mistake (users often fail to set the root URL * correctly, especially when a migration is involved), but the downside * is that unless you are processing a request, this method doesn't work. * * @since 1.263 */ public String getRootUrlFromRequest() { StaplerRequest req = Stapler.getCurrentRequest(); StringBuilder buf = new StringBuilder(); buf.append(req.getScheme() + "://"); buf.append(req.getServerName()); if (req.getServerPort() != 80) { buf.append(':').append(req.getServerPort()); } buf.append(req.getContextPath()).append('/'); return buf.toString(); }
StringBuilder buf = new StringBuilder(req.getScheme()).append("://").append(req.getServerName()); if ((req.getScheme().equals("http") && req.getServerPort()!=80) || (req.getScheme().equals("https") && req.getServerPort()!=443)) buf.append(':').append(req.getServerPort()); url = buf.append(url).toString();
/** * Gets the absolute URL of Hudson top page, such as * "http://localhost/hudson/". * * <p> * Unlike {@link #getRootUrl()}, which uses the manually configured value, * this one uses the current request to reconstruct the URL. The benefit is * that this is immune to the configuration mistake (users often fail to set * the root URL correctly, especially when a migration is involved), but the * downside is that unless you are processing a request, this method doesn't * work. * * @since 1.263 */ public String getRootUrlFromRequest() { StaplerRequest req = Stapler.getCurrentRequest(); StringBuilder buf = new StringBuilder(); buf.append(req.getScheme() + "://"); buf.append(req.getServerName()); if (req.getServerPort() != 80) { buf.append(':').append(req.getServerPort()); } buf.append(req.getContextPath()).append('/'); return buf.toString(); }
String scheme = getXForwardedHeader(req, "X-Forwarded-Proto", req.getScheme()); buf.append(scheme).append("://"); String host = getXForwardedHeader(req, "X-Forwarded-Host", req.getServerName());
StringBuilder buf = new StringBuilder(req.getScheme()).append("://").append(req.getServerName()); if ((req.getScheme().equals("http") && req.getServerPort()!=80) || (req.getScheme().equals("https") && req.getServerPort()!=443)) buf.append(':').append(req.getServerPort()); url = buf.append(url).toString();