import java.io.*;
import java.util.*;
import java.math.BigInteger;


public class HttpHeader
{
	protected long contentLength;
	protected String reply;
	protected String date;
	protected String server;
	protected String lastModified;
	protected String eTag;
	protected String contentRange;
	protected String contentType;
    protected String connection;
    public boolean isRangeSupported;
	
	HttpHeader()
	{
		contentLength = 0;
		reply = null;
		date = null;
		server = null;
		lastModified = null;
		eTag= null;
		contentRange = null;
		contentType = null;
		connection = null;
        isRangeSupported = false;
	}
    int getHeader(DataInputStream inBound)
	{
        String line=null,token=null;
        StringTokenizer tokenizer;

        isRangeSupported = false;
        try
		{
            /**to be read in GetPage
             *  reply = inBound.readLine();
             */
            

            System.out.println("HEADER*********");


            while(!(line = inBound.readLine()).equals(""))
            {

                System.out.println(line);

                tokenizer = new StringTokenizer(line,": ",false);

                
                token = tokenizer.nextToken();

                if(token.equalsIgnoreCase("Content-Length"))
                {
                  BigInteger cl = new BigInteger(tokenizer.nextToken());
                  contentLength =  cl.longValue();
                }
                else
                if(token.equalsIgnoreCase("Content-Range"))
                {
                  isRangeSupported = true;
                  tokenizer.nextToken();
                  while(tokenizer.hasMoreTokens())
                   contentRange=contentRange+tokenizer.nextToken();
      
                }
                else
                if(token.equalsIgnoreCase("Content-Type"))
                {
                    while(tokenizer.hasMoreTokens())
                       contentType = contentType + tokenizer.nextToken();
      
                }

            }
            return -1;

		}
		catch(IOException e)
        {
            System.out.println("Error reading HTTP header" + e);
            return -2;
		}

	}
}

