/** * generates a valid user-agent <br> * something like:<br> * Mozilla/5.0 (Windows; Windows NT 6.1; Windows 7 6.1; U; amd64; de-DE; rv:26.0) Gecko/20100101 Firefox/26.0<br> * but with correct OS and language values */ public static String generateUA() { return generateUA(Locale.getDefault().getLanguage()); }
/** * Instantiates a new url / httpclient with default user-agent. * * @param url * the url */ public Url(String url) throws MalformedURLException { if (client == null) { client = TmmHttpClient.getHttpClient(); } this.url = url; if (url.contains("|")) { splitHeadersFromUrl(); } // morph to URI to check syntax of the url try { uri = morphStringToUri(url); } catch (URISyntaxException e) { throw new MalformedURLException(url); } // default user agent addHeader(USER_AGENT, UrlUtil.generateUA()); }