This is the mail archive of the java-prs@sourceware.cygnus.com mailing list for the Java project.


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

Re: java.net/170: HTTP client code treats headers as body


The following reply was made to PR java.net/170; it has been noted by GNATS.

From: John Stracke <francis@ecal.com>
To: Bryce McKinlay <bryce@albatross.co.nz>, java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: java.net/170: HTTP client code treats headers as body
Date: Thu, 09 Mar 2000 22:07:01 -0500

 John Stracke wrote:
 
 > gcj doesn't currently implement getResponseCode() or
 > getResponseMessage().  I'll
 > write them tonight or tomorrow.
 >
 Oh, and here's the updated test program that prints the response
 code & message along with the headers:
 
 import java.net.*;
 import java.io.*;
 
 public class DemonstrateChunked {
     public static void main(String args[])
     {
  URL url;
 
  try {
      url=new
 URL("http://impp.research.ecal.com/demonstrate.php3");
  } catch (java.net.MalformedURLException malf) {
      System.err.println("Malformed URL: "+malf.getMessage());
      return;
  }
 
  DataInputStream in;
 
  try {
      URLConnection conn=url.openConnection();
 
      if (conn instanceof HttpURLConnection)
   {
       HttpURLConnection httpConn=(HttpURLConnection)conn;
       int status=httpConn.getResponseCode();
       String statusStr=httpConn.getResponseMessage();
       System.out.println("status=="+status);
       System.out.println("statusStr=="+statusStr);
   }
      else
   System.out.println("(Not an HttpURLConnection)");
 
      InputStream _in=conn.getInputStream();
      in=new DataInputStream(_in);
  } catch (IOException io) {
      System.err.println("Can't fetch URL: "+io.getMessage());
      return;
  }
 
  String line;
  try {
      while ((line=in.readLine())!=null)
   System.out.println(line);
  } catch (IOException io) {
      System.out.println("Can't read line from URL:
 "+io.getMessage());
      return;
  }
     }
 };
 
 
 --
 /==============================================================\
 |John Stracke    | http://www.ecal.com |My opinions are my own.|
 |Chief Scientist |=============================================|
 |eCal Corp.      |They prayed for their fates to be quick,     |
 |francis@ecal.com|painless, and, ideally, someone else's.      |
 \==============================================================/
 
 
 

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