// getPage1.java
// Andrew Davison, dandrew@ratree.psu.ac.th, March 1st, 2001

/*
  Download the page "http://www.cs.ait.ac.th/~ad', displaying
  it a line of text at a time.

  Use ProxyDetails class to set proxy and authorization details.
*/


import java.net.*;
import java.io.*;

public class getPage1 
{
  public static void main(String args[]) 
  {
    try {
      ProxyDetails pd = new ProxyDetails(args);
      String enIDPass = pd.getEnIDPass();
      // System.out.println("Encrypted IDPass: " + enIDPass );
          
      URL u  = new URL( "http://www.cs.ait.ac.th/~ad" );
      URLConnection conn = u.openConnection();

      if (enIDPass != null)  // Send auth thougth proxy server
        conn.setRequestProperty("Proxy-Authorization", "Basic " + enIDPass);
      conn.setDoOutput( true );

	  BufferedReader dis = new BufferedReader ( 
	                            new InputStreamReader ( 
                                         conn.getInputStream() ));
      String s ;
      while ( (s=dis.readLine())!=null ) {
        System.out.println( s );
      }
      dis.close();
    } 
	catch (Exception e) 
	{ System.out.println( e ); }

	System.exit(0);

  } // end of main()
 
} // end getPage1 class

