This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcj/14009] New: libgcj HttpURLConnection does not handle situation where retrieving url without training slash after domain.


gnu.java.net.protocol.http.Connection.sendRequest() does not handle situation
where a URL like "http://www.apache.org"; (without trailing slash) is specified.

For the attached example, the following is executed via Sun Java:
  [ken@deviation spider]$ /usr/j2sdk1.4.2_01/bin/javac test.java
  [ken@deviation spider]$ java test apache.org
  Retrieveing: http://apache.org/
  Got: 8613 bytes
  Retrieveing: http://apache.org
  Got: 8613 bytes

When compiled and run with GCJ, the following happens:
  [ken@deviation spider]$ CLASSPATH=/opt/gcc/share/java/libgcj-3.5.0.jar
/opt/gcc/bin/gcj -ggdb -O --main=test test.java -o test &&
LD_LIBRARY_PATH=/opt/gcc/lib ./test apache.org
  Retrieveing: http://apache.org/
  Got: 8613 bytes
  Retrieveing: http://apache.org
  Exception in thread "main" java.io.IOException: Server reply was unparseable:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   at gnu.java.net.protocol.http.Connection.receiveReply()
(/opt/gcc/lib/libgcj.so.6.0.0)
   at gnu.java.net.protocol.http.Connection.connect() (/opt/gcc/lib/libgcj.so.6.0.0)
   at gnu.java.net.protocol.http.Connection.getInputStream()
(/opt/gcc/lib/libgcj.so.6.0.0)
   at test.main(java.lang.String[]) (/home/ken/workspace/spider/test.java:27)

The server-reply-unparseable error is due to the fact that the request was sent
out as "GET  HTTP/1.1", and the webserver just sends back an HTMLified error
page sans the HTTP response headers.

What GCJ should be doing in this case is sending the request as "GET / HTTP/1.1"
and not "GET  HTTP/1.0". One could probably get caught up in the argument
whether the original URL is syntactically correct, but the Sun implementation
works as expected, so the GCJ one should probably try to emulate that behaviour.

-- 
           Summary: libgcj HttpURLConnection does not handle situation where
                    retrieving url without training slash after domain.
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: k dot allan-gcc at au dot darkbluesea dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14009


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]