Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members

HttpGetSocket.java

Go to the documentation of this file.
00001 /*
00002  * HttpGetSocket.java
00003  *
00004  * Created on den 28 oktober 2004, 16:01
00005  */
00006 /*
00007 Copyright (C) 2004  Anders Hedstrom
00008  
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013  
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018  
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022  */
00023 
00024 package net.alhem.jsockets;
00025 
00026 
00027 
00028 
00033 public class HttpGetSocket extends HTTPSocket
00034 {
00035     
00037     public HttpGetSocket(SocketHandler h)
00038     {
00039         super(h);
00040     }
00041     public Socket Create()
00042     {
00043         return new HttpGetSocket(Handler());
00044     }
00045     
00046     public void OnConnect()
00047     {
00048         Send("GET / HTTP/1.0\r\n" +
00049         "Connection: close\r\n" +
00050         "Host: www.alhem.net\r\n" +
00051         "\r\n");
00052     }
00053 
00054     public void OnFirst()
00055     {
00056         if (IsRequest())
00057         {
00058             System.out.println(" * HTTP Request>");
00059             System.out.println(GetMethod());
00060             System.out.println(GetUrl());
00061             System.out.println(GetHttpVersion());
00062         }
00063         if (IsResponse())
00064         {
00065             System.out.println(" * HTTP Response>");
00066             System.out.println(GetHttpVersion());
00067             System.out.println(GetStatus());
00068             System.out.println(GetStatusText());
00069         }
00070     }
00071     
00072     public void OnHeader(String key,String value)
00073     {
00074         System.out.println(" * " + key + ": " + value);
00075     }
00076     
00077     public void OnHeaderComplete()
00078     {
00079         System.out.println("Header Complete");
00080     }
00081     
00082     public void OnData(byte[] buf,int l)
00083     {
00084     }
00085 }

Generated on Fri Oct 29 14:11:17 2004 for Java Sockets by  doxygen 1.3.9.1