// Stapler routes requests like the "/static/.../foo/bar/zot" to be treated like "/foo/bar/zot"
// and this is used to serve long expiration header, by using Jenkins.VERSION_HASH as "..."
// to create unique URLs. Recognize that and set a long expiration header.
String requestPath = req.getRequestURI().substring(req.getContextPath().length());
boolean staticLink = requestPath.startsWith("/static/");
long expires = staticLink ? TimeUnit2.DAYS.toMillis(365) : -1;
// use serveLocalizedFile to support automatic locale selection
rsp.serveLocalizedFile(req, new URL(wrapper.baseResourceURL, '.' + path), expires);
if (size > 0)
{
String language = (String)acceptLanguage.get(0);
language = HttpFields.valueParameters(language,null);
String country = "";
int dash = language.indexOf('-');
if (dash > -1)
{
country = language.substring(dash + 1).trim();
language = language.substring(0,dash).trim();
}
return new Locale(language,country);
}
OpenConnection selectResourceByLocale(URL url, Locale locale) throws IOException { // hopefully HotSpot would be able to inline all the virtual calls in here
return urlLocaleSelector.open(url.toString(),locale,url);
private abstract>/** * The 'path' is divided into the base part and the extension, and the locale-specific
* suffix is inserted to the base portion. {@link #map(String)} is used to convert
* the combined path into {@link URL}, until we find one that works.
*
*
* The syntax of the locale specific resource is the same as property file localization.
* So Japanese resource for foo.html would be named foo_ja.html.
*
* @param path
* path/URL-like string that represents the path of the base resource,
* say "foo/bar/index.html" or "file:///a/b/c/d/efg.png"
* @param locale
* The preferred locale
* @param fallback
* The {@link URL} representation of the {@code path} parameter
* Used as a fallback.
*/
OpenConnection open(String path, Locale locale, URL fallback) throws IOException {
String s = path;
int> if(idx=0) // the '.' we found was not an extension separator
return openURL(fallback);