/** * This file contains example code from the book * JAVA NETWORKING AND COMMUNICATIONS * by Todd Courtois * ISBN 0-13-850454-7 * * Purchasers of the book may reuse this sample code * for any purpose whatsoever as long as this header * is included. Use of this example code is subject * to the license agreement printed in the book. * * For updates see the web site * http://www.rawthought.com/JNC/ */ /** * Modified by Michael Hicks for CMSC 433, * University of Maryland, 2002. */ import java.io.*; import java.net.*; import java.util.*; /** * An object encapsulating an HTTP request */ public abstract class HttpRequest { //response status constants public final static int REPLY_ERROR_NO_ERROR = 200, REPLY_ERROR_NO_SUCH_FILE = 404; public final static String REPLY_EXPLANATION_OK = " OK ",//no problem REPLY_EXPLANATION_ERROR = " ERROR ";//error of some sort //info about the content file private String HTTPversion; // e.g. HTTP/1.0 private String requestType; // e.g. GET private String requestName; // e.g. /filename.html protected HttpRequest(String request, String version, String type) { requestName = request; HTTPversion = version; requestType = type; } public String getRequestName() { return requestName; } public String getRequestType() { return requestType; } public String getHTTPversion() { return HTTPversion; } public String toString() { return requestType+" "+requestName+" "+HTTPversion; } }