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; }