avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl URLSource.java
Date Fri, 07 Nov 2003 08:18:45 GMT
cziegeler    2003/11/07 00:18:45

  Modified:    sourceresolve/src/java/org/apache/excalibur/source/impl
                        URLSource.java
  Log:
  Applying patch from Martin Holz:
   URLSource decode userinfo
  
  Revision  Changes    Path
  1.26      +28 -5     avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java
  
  Index: URLSource.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- URLSource.java	3 Jul 2003 15:23:34 -0000	1.25
  +++ URLSource.java	7 Nov 2003 08:18:45 -0000	1.26
  @@ -56,9 +56,11 @@
   
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.UnsupportedEncodingException;
   import java.net.HttpURLConnection;
   import java.net.URL;
   import java.net.URLConnection;
  +import java.net.URLDecoder;
   import java.util.Iterator;
   import java.util.Map;
   
  @@ -179,9 +181,8 @@
                   if (null == m_connection)
                   {
                       m_connection = m_url.openConnection();
  -                    String userInfo = m_url.getUserInfo();
  -                    if (m_url.getProtocol().startsWith("http") && userInfo != null)
  -                    {
  +                    String userInfo = getUserInfo();
  +                    if (m_url.getProtocol().startsWith("http") && userInfo != null){
                           m_connection.setRequestProperty("Authorization", "Basic " + SourceUtil.encodeBASE64(userInfo));
                       }
                   }
  @@ -226,7 +227,7 @@
           {
               m_connection = m_url.openConnection();
   
  -            String userInfo = m_url.getUserInfo();
  +            String userInfo = getUserInfo();
               if (m_url.getProtocol().startsWith("http") && userInfo != null)
               {
                   m_connection.setRequestProperty("Authorization", "Basic " + SourceUtil.encodeBASE64(userInfo));
  @@ -322,5 +323,27 @@
       public String getMimeType()
       {
           return m_mimeType;
  +    }
  +    
  +    /**
  +     * The decoded userinfo for this source.
  +     * null, if no userinfo exists 
  +     */
  +    protected String getUserInfo() 
  +    {
  +	    if (m_url == null) return null;
  +	    String ui = m_url.getUserInfo();
  +	    if (ui == null) return null;
  +	
  +	    try 
  +        {
  +	        ui = URLDecoder.decode(ui,"UTF-8");
  +	    } 
  +        catch (UnsupportedEncodingException e)
  +        {
  +	        // Platform does not support UTF-8. This should never happen.
  +	        // e.printStackTrace();
  +	    }
  +	    return ui;
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message