001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestLine.java,v 1.6 2002/03/18 07:15:40 remm Exp $
003: * $Revision: 1.6 $
004: * $Date: 2002/03/18 07:15:40 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina.connector.http;
065:
066: import java.io.IOException;
067: import java.net.InetAddress;
068: import javax.servlet.ServletInputStream;
069: import org.apache.catalina.connector.HttpRequestBase;
070:
071: /**
072: * HTTP request line enum type.
073: *
074: * @author Remy Maucherat
075: * @version $Revision: 1.6 $ $Date: 2002/03/18 07:15:40 $
076: * @deprecated
077: */
078:
079: final class HttpRequestLine {
080:
081: // -------------------------------------------------------------- Constants
082:
083: public static final int INITIAL_METHOD_SIZE = 8;
084: public static final int INITIAL_URI_SIZE = 64;
085: public static final int INITIAL_PROTOCOL_SIZE = 8;
086: public static final int MAX_METHOD_SIZE = 1024;
087: public static final int MAX_URI_SIZE = 32768;
088: public static final int MAX_PROTOCOL_SIZE = 1024;
089:
090: // ----------------------------------------------------------- Constructors
091:
092: public HttpRequestLine() {
093:
094: this (new char[INITIAL_METHOD_SIZE], 0,
095: new char[INITIAL_URI_SIZE], 0,
096: new char[INITIAL_PROTOCOL_SIZE], 0);
097:
098: }
099:
100: public HttpRequestLine(char[] method, int methodEnd, char[] uri,
101: int uriEnd, char[] protocol, int protocolEnd) {
102:
103: this .method = method;
104: this .methodEnd = methodEnd;
105: this .uri = uri;
106: this .uriEnd = uriEnd;
107: this .protocol = protocol;
108: this .protocolEnd = protocolEnd;
109:
110: }
111:
112: // ----------------------------------------------------- Instance Variables
113:
114: public char[] method;
115: public int methodEnd;
116: public char[] uri;
117: public int uriEnd;
118: public char[] protocol;
119: public int protocolEnd;
120:
121: // ------------------------------------------------------------- Properties
122:
123: // --------------------------------------------------------- Public Methods
124:
125: /**
126: * Release all object references, and initialize instance variables, in
127: * preparation for reuse of this object.
128: */
129: public void recycle() {
130:
131: methodEnd = 0;
132: uriEnd = 0;
133: protocolEnd = 0;
134:
135: }
136:
137: /**
138: * Test if the uri includes the given char array.
139: */
140: public int indexOf(char[] buf) {
141: return indexOf(buf, buf.length);
142: }
143:
144: /**
145: * Test if the value of the header includes the given char array.
146: */
147: public int indexOf(char[] buf, int end) {
148: char firstChar = buf[0];
149: int pos = 0;
150: while (pos < uriEnd) {
151: pos = indexOf(firstChar, pos);
152: if (pos == -1)
153: return -1;
154: if ((uriEnd - pos) < end)
155: return -1;
156: for (int i = 0; i < end; i++) {
157: if (uri[i + pos] != buf[i])
158: break;
159: if (i == (end - 1))
160: return pos;
161: }
162: pos++;
163: }
164: return -1;
165: }
166:
167: /**
168: * Test if the value of the header includes the given string.
169: */
170: public int indexOf(String str) {
171: return indexOf(str.toCharArray(), str.length());
172: }
173:
174: /**
175: * Returns the index of a character in the value.
176: */
177: public int indexOf(char c, int start) {
178: for (int i = start; i < uriEnd; i++) {
179: if (uri[i] == c)
180: return i;
181: }
182: return -1;
183: }
184:
185: // --------------------------------------------------------- Object Methods
186:
187: public int hashCode() {
188: // FIXME
189: return 0;
190: }
191:
192: public boolean equals(Object obj) {
193: return false;
194: }
195:
196: }
|