List of usage examples for org.apache.wicket.request Url parse
public static Url parse(CharSequence _url, Charset charset, boolean isFullHint)
From source file:com.mastfrog.acteur.wicket.adapters.RequestAdapter.java
License:Open Source License
@Inject public RequestAdapter(HttpEvent evt, Locale locale, Charset charset, Settings settings) { this.evt = evt; this.locale = locale; this.charset = charset; String filterPrefix = settings.getString(PathFactory.BASE_PATH_SETTINGS_KEY, ""); String uri = evt.getRequest().getUri(); // Adapted from ServletWebRequest's constructor if (filterPrefix.length() > 0 && !filterPrefix.endsWith("/")) { filterPrefix += "/"; }/*from w w w . j a v a 2 s . c om*/ StringBuilder sb = new StringBuilder(); uri = Strings.stripJSessionId(uri); String contextPath = ""; final int start = contextPath.length() + filterPrefix.length() + 1; if (uri.length() > start) { sb.append(uri.substring(start)); } Url url = Url.parse(sb.toString(), charset, false); url.setPort(settings.getInt(ServerModule.PORT)); String host = evt.getHeader(Headers.HOST); if (host != null) { url.setHost(host); } else { url.setHost(settings.getString(PathFactory.HOSTNAME_SETTINGS_KEY, "localhost")); } url.setProtocol("http"); this.url = url; }