EX_0.X-1055

Issue #74 new
Laurent Forêt created an issue

Pour garantir le fonctionnement du système, le LPS doit savoir gérer les redirections HTTPS 3xx émises par le système DMP.

Comments (1)

  1. Laurent Forêt reporter

    Afin de récupérer l’url de redirection, une classe java utilitaire nous permet de récupérer l’url finale :

    public String getFinalURL(String url) throws IOException {
            HttpURLConnection con = (HttpURLConnection) noCheckCertificateOpenConnection(url);
            con.setInstanceFollowRedirects(false);
            con.connect();
            con.getInputStream();
    
            if (con.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM 
                    || con.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP
                    || con.getResponseCode() == HttpURLConnection.HTTP_SEE_OTHER) {
                String redirectUrl = con.getHeaderField("Location");
                return getFinalURL(redirectUrl);
            }
            return url;
        }
    

  2. Log in to comment