[kaffe] HttpURLConnection CVS regression from 1.0.7

Dalibor Topic robilad@yahoo.com
Wed May 7 01:11:02 2003


In-Reply-To: <1051444889.6017.26.camel@elsschot>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

Hi Jukka,

since you wrote the last HTTP proxy handling patch, could you take a look at
this one?

cheers,
dalibor topic

--- Mark Wielaard <mark@klomp.org> wrote:
> Hi,
> 
> I have a little snippet of code (adapted to work standalone) that works
> with kaffe 1.0.7 but not with the CVS version:
> 
> import java.io.*;
> import java.net.*;
>  
> public class TC
> {
>   public static void main(String[] args) throws Exception
>   {
>     URL u = new URL("http://www.gnu.org/");
>     URLConnection c = u.openConnection();
>     c.connect();
>     InputStream in = c.getInputStream();
>  
>     if (c instanceof HttpURLConnection)
>       {
>         // Check whether the page exists
>         int code = ((HttpURLConnection)c).getResponseCode();
>         if (code/100 != 2) // We can only handle 200 OK
>           {
>             System.err.println("Loading page gave error code "
>                       + code + ", it probably doesn't exists");
>             return;
>           }
>       }
>  
>     // Do something with the inputstream
>     System.out.println("Yeah!");
>   }
> }
> 
> With kaffe from CVS it always gives reponse code -1.
> This seems to be caused by a combination of the new proxy activation
> code in
> kaffe/net/www/protocol/http/HttpURLConnection.java
> which precents creation of a new socket everytime which the old code did
> on a connect (since the socket == null check was missing) and the fact
> that connect is called from both URL.openConnection() and the above
> URLConnection.connect() in my code.
> 
> It seems a good idea to not call connect() in openConnection() as done
> in this patch, but I have not thought this through completely.
> 
> diff -u -r1.29 URL.java
> --- libraries/javalib/java/net/URL.java 15 Apr 2002 15:10:01 -0000      1.29
> +++ libraries/javalib/java/net/URL.java 27 Apr 2003 11:52:55 -0000
> @@ -229,7 +229,6 @@
>         // We *ALWAYS* open a new connection even if we already have
>         // one open.
>         conn = handler.openConnection(this);
> -       conn.connect();
>         return (conn);
>  }
> 
> Cheers,
> 
> Mark
> 
> 
> _______________________________________________
> kaffe mailing list
> kaffe@kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com