canvas-api/src/main/java/com/instructure/canvasapi/api/compatibility_synchronous/HttpHelpers.java
/**
     * redirectURL tries its best to follow http redirects until there are no more.
     * @param urlConnection
     * @return
     */
redirectURL tries its best to follow http redirects until there are no more.
@param urlConnection
@return
redirectURL tries its best to follow http redirects until there are no more . @param urlConnection @return
@TargetApi(9)
    public static HttpURLConnection redirectURL(HttpURLConnection urlConnection) {
        HttpURLConnection.setFollowRedirects(true);
        try {
            urlConnection.connect();
            String currentURL = urlConnection.getURL().toString();
            do
            {
                urlConnection.getResponseCode();
                currentURL = urlConnection.getURL().toString();
                urlConnection = (HttpURLConnection) new URL(currentURL).openConnection();
            }
            while (!urlConnection.getURL().toString().equals(currentURL));
        } catch(Exception E){}
        return urlConnection;
    }
@ TargetApi ( 9 ) public static HttpURLConnection redirectURL ( HttpURLConnection urlConnection ) { HttpURLConnection . setFollowRedirects ( true ) ; try { urlConnection . connect ( ) ; String currentURL = urlConnection . getURL ( ) . toString ( ) ; do { urlConnection . getResponseCode ( ) ; currentURL = urlConnection . getURL ( ) . toString ( ) ; urlConnection = ( HttpURLConnection ) new URL ( currentURL ) . openConnection ( ) ; } while ( ! urlConnection . getURL ( ) . toString ( ) . equals ( currentURL ) ) ; } catch ( Exception E ) { } return urlConnection ; }
redirectURL tries its best to follow http redirects until there are no more.
redirectURL tries its best to follow http redirects until there are no more .