harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3717) [classlib][luni] java.net.HttpURLConnection.getResponseCode() anomoly
Date Fri, 23 Nov 2007 23:43:43 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545138
] 

Tim Ellison commented on HARMONY-3717:
--------------------------------------

Thanks for the analysis Chris.

The problem is that we don't go through the proxy selector when sending a request for the
default response code (GET) , so the test in o.a.h.luni.internal.net.www.protocol.http.HttpURLConnection#requestString()
thinks we are not using a proxy.

The fix is to invoke connect() -- but without further testing I'm not sure if we should be
left connected after getResponseCode(), so may require further investigation.  If not we have
to invoke the selector separately.  I also don't have a real proxy handy to test with.

My suggested fix is below, but I won't commit it until a bit more testing and somebody with
a proxy can verify it for me.

Index: src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
===================================================================
--- src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(revision 597734)
+++ src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(working copy)
@@ -1081,6 +1081,7 @@
         // Response Code Sample : "HTTP/1.0 200 OK"
 
         // Call connect() first since getHeaderField() doesn't return exceptions
+        connect();
         doRequest();
         if (responseCode != -1) {
             return responseCode;


> [classlib][luni] java.net.HttpURLConnection.getResponseCode() anomoly
> ---------------------------------------------------------------------
>
>                 Key: HARMONY-3717
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3717
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, Classlib
>         Environment: Windows XP SP2
> c:\java\hre50\bin\java -version
> svn = r530500, (Apr 20 2007), Windows/ia32/msvc 1310, release build
>            Reporter: Chris Elford
>            Priority: Minor
>         Attachments: http.java, network.txt
>
>
> I am trying to see if OpenJNLP works with Harmony.  OpenJNLP is a pretty old implementation
of the JNLP protocol w/o security.  I hacked OpenJNLP to recognize Windows XP and then try
to load a jnlp app from the the web (http://www.eclipse.org/swt/jws/controlexample.jnlp in
this case).  It fails with 
> java.io.IOException: Bad Request
>         at org.nanode.jnlp.JNLPParser$URLJNLPParser.openInputStream(JNLPParser.java:491)
>         at org.nanode.jnlp.JNLPParser.parse(JNLPParser.java:119)
>         at org.nanode.jnlp.JNLPParser.parseDescriptor(JNLPParser.java:292)
>         at org.nanode.app.openjnlp.DefaultAppHandler.handleOpenURL(Unknown Source)
>         at org.nanode.app.OpenJNLP.main(Unknown Source)
> Launching failed: http://www.eclipse.org/swt/jws/controlexample.jnlp
> [It works with the Sun JVM].  
> Instrumenting the code shows that the following basic code is executed
> URLConnection uc = srcURL.openConnection();
>  if (uc instanceof HttpURLConnection) {
>      HttpURLConnection huc = (HttpURLConnection) uc;
>      if (huc.getResponseCode() != HttpURLConnection.HTTP_OK) {
>          throw new IOException(huc.getResponseMessage());
>     }
> }
> getResponseCode() is returning error 400 and thus the app throws the exception.  I noted
that if I insert a call to huc.getHeaderFields() before the if that checks the response code,
I will subsequently get a response 200 (HTTP_OK) and things proceed.  It appears like there
is some sort of race or deferral in populating the response codes here.  Note that instead
of calling huc.getHeaderFields(), I tried putting a 5 sec sleep in and it did NOT fix it.
 It doesn't look like it is a normal race.
> Note that it works with the Sun VM without any mods at all.
> Note that I am using a proxy server via -Dproxyset=true -DproxyHost=xxx -DproxyPort=yyy
at the java command line.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message