/** * @param value true if redirects should be followed across protocols, false otherwise. * @return a copy of the current object with followRedirects set to the new value. */ public OWLOntologyLoaderConfiguration setFollowRedirects(boolean value) { // as the objects are immutable, setting to the same value returns the // same object if (value == isFollowRedirects()) { return this; } OWLOntologyLoaderConfiguration copy = copyConfiguration(); copy.overrides.put(FOLLOW_REDIRECTS, Boolean.valueOf(value)); return copy; }
/** * @param value true if redirects should be followed across protocols, false otherwise. * @return a copy of the current object with followRedirects set to the new value. */ public OWLOntologyLoaderConfiguration setFollowRedirects(boolean value) { // as the objects are immutable, setting to the same value returns the // same object if (value == isFollowRedirects()) { return this; } OWLOntologyLoaderConfiguration copy = copyConfiguration(); copy.overrides.put(FOLLOW_REDIRECTS, Boolean.valueOf(value)); return copy; }
/** * @param value true if redirects should be followed across protocols, false otherwise. * @return a copy of the current object with followRedirects set to the new value. */ public OWLOntologyLoaderConfiguration setFollowRedirects(boolean value) { // as the objects are immutable, setting to the same value returns the // same object if (value == isFollowRedirects()) { return this; } OWLOntologyLoaderConfiguration copy = copyConfiguration(); copy.overrides.put(FOLLOW_REDIRECTS, Boolean.valueOf(value)); return copy; }
protected static URLConnection connect(OWLOntologyLoaderConfiguration config, String originalProtocol, URLConnection conn, int connectionTimeout, String acceptHeaders) throws IOException { if (conn instanceof HttpURLConnection && config.isFollowRedirects()) { // follow redirects to HTTPS HttpURLConnection con = (HttpURLConnection) conn; con.connect(); int responseCode = con.getResponseCode(); // redirect if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_SEE_OTHER) { String location = con.getHeaderField("Location"); URL newURL = new URL(location); String newProtocol = newURL.getProtocol(); if (!originalProtocol.equals(newProtocol)) { // then different protocols: redirect won't follow // automatically return rebuildConnection(config, connectionTimeout, newURL, acceptHeaders); } } } return conn; }
protected static URLConnection connect(OWLOntologyLoaderConfiguration config, String originalProtocol, URLConnection conn, int connectionTimeout, String acceptHeaders) throws IOException { if (conn instanceof HttpURLConnection && config.isFollowRedirects()) { // follow redirects to HTTPS HttpURLConnection con = (HttpURLConnection) conn; con.connect(); int responseCode = con.getResponseCode(); // redirect if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_SEE_OTHER) { String location = con.getHeaderField("Location"); URL newURL = new URL(location); String newProtocol = newURL.getProtocol(); if (!originalProtocol.equals(newProtocol)) { // then different protocols: redirect won't follow // automatically return rebuildConnection(config, connectionTimeout, newURL, acceptHeaders); } } } return conn; }
protected static URLConnection connect(OWLOntologyLoaderConfiguration config, String originalProtocol, URLConnection conn, int connectionTimeout, String acceptHeaders) throws IOException { if (conn instanceof HttpURLConnection && config.isFollowRedirects()) { // follow redirects to HTTPS HttpURLConnection con = (HttpURLConnection) conn; con.connect(); int responseCode = con.getResponseCode(); // redirect if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_SEE_OTHER) { String location = con.getHeaderField("Location"); URL newURL = new URL(location); String newProtocol = newURL.getProtocol(); if (!originalProtocol.equals(newProtocol)) { // then different protocols: redirect won't follow // automatically return rebuildConnection(config, connectionTimeout, newURL, acceptHeaders); } } } return conn; }