remm 00/11/24 11:55:21
Modified: catalina/src/share/org/apache/catalina/connector/http
HttpHeader.java HttpProcessor.java
HttpRequestImpl.java HttpRequestLine.java
Added: catalina/src/share/org/apache/catalina/connector/http
DefaultHeaders.java
Log:
- Start using the new buffers in the request, to test their functionality.
- Use the modified request in the processor.
- The request parsing still needs more optimization, and the response hasn't
been optimized at all. A profiling session would probably be very useful
before doing any additional work.
Revision Changes Path
1.2 +169 -6
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpHeader.java
Index: HttpHeader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpHeader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpHeader.java 2000/11/17 03:30:43 1.1
+++ HttpHeader.java 2000/11/24 19:55:20 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpHeader.java,v
1.1 2000/11/17 03:30:43 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/11/17 03:30:43 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpHeader.java,v
1.2 2000/11/24 19:55:20 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/11/24 19:55:20 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
* HTTP header enum type.
*
* @author Remy Maucherat
- * @version $Revision: 1.1 $ $Date: 2000/11/17 03:30:43 $
+ * @version $Revision: 1.2 $ $Date: 2000/11/24 19:55:20 $
*/
final class HttpHeader {
@@ -110,6 +110,16 @@
}
+ public HttpHeader(String name, String value) {
+
+ this.name = name.toLowerCase().toCharArray();
+ this.nameEnd = name.length();
+ this.value = value.toCharArray();
+ this.valueEnd = value.length();
+
+ }
+
+
// ----------------------------------------------------- Instance Variables
@@ -117,6 +127,7 @@
public int nameEnd;
public char[] value;
public int valueEnd;
+ protected int hashCode = 0;
// ------------------------------------------------------------- Properties
@@ -133,20 +144,172 @@
nameEnd = 0;
valueEnd = 0;
+ hashCode = 0;
+
+ }
+
+
+ /**
+ * Test if the name of the header is equal to the given char array.
+ * All the characters must already be lower case.
+ */
+ public boolean equals(char[] buf) {
+ return equals(buf, buf.length);
+ }
+
+
+ /**
+ * Test if the name of the header is equal to the given char array.
+ * All the characters must already be lower case.
+ */
+ public boolean equals(char[] buf, int end) {
+ if (end != nameEnd)
+ return false;
+ for (int i=0; i<end; i++) {
+ if (buf[i] != name[i])
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Test if the name of the header is equal to the given string.
+ * The String given must be made of lower case characters.
+ */
+ public boolean equals(String str) {
+ return equals(str.toCharArray(), str.length());
}
+ /**
+ * Test if the value of the header is equal to the given char array.
+ */
+ public boolean valueEquals(char[] buf) {
+ return valueEquals(buf, buf.length);
+ }
+
+
+ /**
+ * Test if the value of the header is equal to the given char array.
+ */
+ public boolean valueEquals(char[] buf, int end) {
+ if (end != valueEnd)
+ return false;
+ for (int i=0; i<end; i++) {
+ if (buf[i] != value[i])
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * Test if the value of the header is equal to the given string.
+ */
+ public boolean valueEquals(String str) {
+ return valueEquals(str.toCharArray(), str.length());
+ }
+
+
+ /**
+ * Test if the value of the header includes the given char array.
+ */
+ public boolean valueIncludes(char[] buf) {
+ return valueIncludes(buf, buf.length);
+ }
+
+
+ /**
+ * Test if the value of the header includes the given char array.
+ */
+ public boolean valueIncludes(char[] buf, int end) {
+ char firstChar = buf[0];
+ int pos = 0;
+ while (pos < valueEnd) {
+ pos = valueIndexOf(firstChar, pos);
+ if (pos == -1)
+ return false;
+ if ((valueEnd - pos) < end)
+ return false;
+ for (int i = 0; i < end; i++) {
+ if (value[i + pos] != buf[i])
+ break;
+ if (i == (end-1))
+ return true;
+ }
+ pos++;
+ }
+ return false;
+ }
+
+
+ /**
+ * Test if the value of the header includes the given string.
+ */
+ public boolean valueIncludes(String str) {
+ return valueIncludes(str.toCharArray(), str.length());
+ }
+
+
+ /**
+ * Returns the index of a character in the value.
+ */
+ public int valueIndexOf(char c, int start) {
+ for (int i=start; i<valueEnd; i++) {
+ if (value[i] == c)
+ return i;
+ }
+ return -1;
+ }
+
+
+ /**
+ * Test if the name of the header is equal to the given header.
+ * All the characters in the name must already be lower case.
+ */
+ public boolean equals(HttpHeader header) {
+ return (equals(header.name, header.nameEnd));
+ }
+
+
+ /**
+ * Test if the name and value of the header is equal to the given header.
+ * All the characters in the name must already be lower case.
+ */
+ public boolean headerEquals(HttpHeader header) {
+ return (equals(header.name, header.nameEnd))
+ && (valueEquals(header.value, header.valueEnd));
+ }
+
+
// --------------------------------------------------------- Object Methods
+ /**
+ * Return hash code. The hash code of the HttpHeader object is the same
+ * as returned by new String(name, 0, nameEnd).hashCode().
+ */
public int hashCode() {
- // FIXME
- return 0;
+ int h = hashCode;
+ if (h == 0) {
+ int off = 0;
+ char val[] = name;
+ int len = nameEnd;
+ for (int i = 0; i < len; i++)
+ h = 31*h + val[off++];
+ hashCode = h;
+ }
+ return h;
}
public boolean equals(Object obj) {
+ if (obj instanceof String) {
+ return equals(((String) obj).toLowerCase());
+ } else if (obj instanceof HttpHeader) {
+ return equals((HttpHeader) obj);
+ }
return false;
}
1.13 +53 -54
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java
Index: HttpProcessor.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- HttpProcessor.java 2000/11/17 03:30:43 1.12
+++ HttpProcessor.java 2000/11/24 19:55:20 1.13
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.12 2000/11/17 03:30:43 remm Exp $
- * $Revision: 1.12 $
- * $Date: 2000/11/17 03:30:43 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.13 2000/11/24 19:55:20 remm Exp $
+ * $Revision: 1.13 $
+ * $Date: 2000/11/24 19:55:20 $
*
* ====================================================================
*
@@ -106,7 +106,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.12 $ $Date: 2000/11/17 03:30:43 $
+ * @version $Revision: 1.13 $ $Date: 2000/11/24 19:55:20 $
*/
final class HttpProcessor
@@ -128,8 +128,8 @@
this.connector = connector;
this.debug = connector.getDebug();
this.id = id;
- this.request = (HttpRequest) connector.createRequest();
- this.response = (HttpResponse) connector.createResponse();
+ this.request = (HttpRequestImpl) connector.createRequest();
+ this.response = (HttpResponseImpl) connector.createResponse();
this.threadName =
"HttpProcessor[" + connector.getPort() + "][" + id + "]";
@@ -177,6 +177,12 @@
/**
+ * The match string for identifying a session ID parameter.
+ */
+ private static final char[] SESSION_ID = match.toCharArray();
+
+
+ /**
* The string parser we will use for parsing request lines.
*/
private StringParser parser = new StringParser();
@@ -185,13 +191,13 @@
/**
* The HTTP request object we will pass to our associated container.
*/
- private HttpRequest request = null;
+ private HttpRequestImpl request = null;
/**
* The HTTP response object we will pass to our associated container.
*/
- private HttpResponse response = null;
+ private HttpResponseImpl response = null;
/**
@@ -275,7 +281,7 @@
/**
* Line buffer.
*/
- private char[] lineBuffer = new char[4096];
+ //private char[] lineBuffer = new char[4096];
/**
@@ -284,12 +290,6 @@
private HttpRequestLine requestLine = new HttpRequestLine();
- /**
- * HTTP header.
- */
- private HttpHeader header = new HttpHeader();
-
-
// -------------------------------------------------------- Package Methods
@@ -520,12 +520,10 @@
while (true) {
- try {
- // Read the next header
- input.readHeader(header);
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ HttpHeader header = request.allocateHeader();
+
+ // Read the next header
+ input.readHeader(header);
if (header.nameEnd == 0) {
if (header.valueEnd == 0) {
return;
@@ -535,19 +533,16 @@
}
}
- String name = new String(header.name, 0, header.nameEnd);
- String match = name;
String value = new String(header.value, 0, header.valueEnd);
- //System.out.println(" Header:" + name + "_ Value:" + value + "_");
- if (debug >= 1)
- log(" Header " + name + " = " + value);
+ //if (debug >= 1)
+ // log(" Header " + name + " = " + value);
// Set the corresponding request headers
- if (match.equals("authorization")) {
- request.setAuthorization(value);
- } else if (match.equals("accept-language")) {
- parseAcceptLanguage(value);
- } else if (match.equals("cookie")) {
+ if (header.equals(DefaultHeaders.AUTHORIZATION_NAME)) {
+ request.setAuthorization(value);
+ } else if (header.equals(DefaultHeaders.ACCEPT_LANGUAGE_NAME)) {
+ parseAcceptLanguage(value);
+ } else if (header.equals(DefaultHeaders.COOKIE_NAME)) {
Cookie cookies[] = RequestUtil.parseCookieHeader(value);
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals
@@ -566,7 +561,7 @@
}
request.addCookie(cookies[i]);
}
- } else if (match.equals("content-length")) {
+ } else if (header.equals(DefaultHeaders.CONTENT_LENGTH_NAME)) {
int n = -1;
try {
n = Integer.parseInt(value);
@@ -576,9 +571,9 @@
("httpProcessor.parseHeaders.contentLength"));
}
request.setContentLength(n);
- } else if (match.equals("content-type")) {
+ } else if (header.equals(DefaultHeaders.CONTENT_TYPE_NAME)) {
request.setContentType(value);
- } else if (match.equals("host")) {
+ } else if (header.equals(DefaultHeaders.HOST_NAME)) {
int n = value.indexOf(":");
if (n < 0)
request.setServerName(value);
@@ -594,24 +589,27 @@
}
request.setServerPort(port);
}
- } else if (match.equals("connection")) {
- if ("close".equalsIgnoreCase(value)) {
+ } else if (header.equals(DefaultHeaders.CONNECTION_NAME)) {
+ if (header.valueEquals
+ (DefaultHeaders.CONNECTION_CLOSE_VALUE)) {
keepAlive = false;
}
+ //request.setConnection(header);
/*
if ("keep-alive".equalsIgnoreCase(value)) {
keepAlive = true;
}
*/
- } else if (match.equals("expect")) {
- if ("100-continue".equalsIgnoreCase(value))
+ } else if (header.equals(DefaultHeaders.EXPECT_NAME)) {
+ if (header.valueEquals(DefaultHeaders.EXPECT_100_VALUE))
sendAck = true;
else
throw new ServletException
(sm.getString
("httpProcessor.parseHeaders.unknownExpectation"));
+ } else if (header.equals(DefaultHeaders.TRANSFER_ENCODING_NAME)) {
+ //request.setTransferEncoding(header);
}
- request.addHeader(name, value);
}
}
@@ -634,9 +632,9 @@
input.readRequestLine(requestLine);
String method =
new String(requestLine.method, 0, requestLine.methodEnd);
- String uri = new String(requestLine.uri, 0, requestLine.uriEnd);
+ String uri = null;
String protocol = new String(requestLine.protocol, 0,
- requestLine.protocolEnd);
+ requestLine.protocolEnd);
//System.out.println(" Method:" + method + "_ Uri:" + uri
// + "_ Protocol:" + protocol);
@@ -661,22 +659,25 @@
if (method.length() < 1) {
throw new ServletException
(sm.getString("httpProcessor.parseRequest.method"));
- } else if (uri.length() < 1) {
+ } else if (requestLine.uriEnd < 1) {
throw new ServletException
(sm.getString("httpProcessor.parseRequest.uri"));
}
// Parse any query parameters out of the request URI
- int question = uri.indexOf("?");
+ int question = requestLine.indexOf("?");
if (question >= 0) {
- request.setQueryString(uri.substring(question + 1));
+ request.setQueryString
+ (new String(requestLine.uri, 0, question + 1));
if (debug >= 1)
log(" Query string is " +
((HttpServletRequest) request.getRequest())
.getQueryString());
- uri = uri.substring(0, question);
- } else
+ uri = new String(requestLine.uri, 0, question);
+ } else {
request.setQueryString(null);
+ uri = new String(requestLine.uri, 0, requestLine.uriEnd);
+ }
// Parse any requested session ID out of the request URI
int semicolon = uri.indexOf(match);
@@ -781,12 +782,11 @@
ackRequest(output);
// If the protocol is HTTP/1.1, chunking is allowed.
if (connector.isChunkingAllowed())
- ((HttpResponseImpl) response)
- .setAllowChunking(true);
+ response.setAllowChunking(true);
}
}
} catch (EOFException e) {
- // log("process.parse: EOFException: " + e);
+ //log("process.parse: EOFException: " + e);
ok = false;
} catch (Exception e) {
try {
@@ -829,8 +829,8 @@
// Finish up the handling of the request
try {
if (ok) {
- ((HttpResponseImpl) response).finishResponse();
- ((HttpRequestImpl) request).finishRequest();
+ response.finishResponse();
+ request.finishRequest();
}
if (output != null)
output.flush();
@@ -841,12 +841,11 @@
// We have to check if the connection closure has been requested
// by the application or the response stream (in case of HTTP/1.0
// and keep-alive).
- if ( "close".equals(((HttpResponseImpl) response)
- .getHeader("Connection")) ) {
+ if ( "close".equals(response.getHeader("Connection")) ) {
keepAlive = false;
}
// If the status is an error, the connection is closed
- if ( ((HttpResponseImpl) response).getStatus() >= 400 ) {
+ if (response.getStatus() >= 400) {
keepAlive = false;
}
1.3 +185 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java
Index: HttpRequestImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpRequestImpl.java 2000/10/10 17:09:24 1.2
+++ HttpRequestImpl.java 2000/11/24 19:55:20 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v
1.2 2000/10/10 17:09:24 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/10 17:09:24 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v
1.3 2000/11/24 19:55:20 remm Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/11/24 19:55:20 $
*
* ====================================================================
*
@@ -67,21 +67,40 @@
import java.io.IOException;
import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Enumeration;
import javax.servlet.ServletInputStream;
import org.apache.catalina.connector.HttpRequestBase;
+import org.apache.catalina.util.Enumerator;
/**
* Implementation of <b>HttpRequest</b> specific to the HTTP connector.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/10 17:09:24 $
+ * @author Remy Maucherat
+ * @version $Revision: 1.3 $ $Date: 2000/11/24 19:55:20 $
*/
final class HttpRequestImpl
extends HttpRequestBase {
+ // -------------------------------------------------------------- Constants
+
+
+ /**
+ * Initial pool size.
+ */
+ protected static final int INITIAL_POOL_SIZE = 10;
+
+
+ /**
+ * Pool size increment.
+ */
+ protected static final int POOL_SIZE_INCREMENT = 5;
+
+
// ----------------------------------------------------- Instance Variables
@@ -98,6 +117,30 @@
"org.apache.catalina.connector.http.HttpRequestImpl/1.0";
+ /**
+ * Headers pool.
+ */
+ protected HttpHeader[] headerPool = new HttpHeader[INITIAL_POOL_SIZE];
+
+
+ /**
+ * Position of the next available header in the pool.
+ */
+ protected int nextHeader = 0;
+
+
+ /**
+ * Connection header.
+ */
+ protected HttpHeader connectionHeader = null;
+
+
+ /**
+ * Transfer encoding header.
+ */
+ protected HttpHeader transferEncodingHeader = null;
+
+
// ------------------------------------------------------------- Properties
@@ -148,6 +191,8 @@
super.recycle();
inet = null;
+ nextHeader = 0;
+ connectionHeader = null;
}
@@ -167,6 +212,84 @@
}
+ /**
+ * Allocate new header.
+ *
+ * @return an HttpHeader buffer allocated from the pool
+ */
+ HttpHeader allocateHeader() {
+ if (nextHeader == headerPool.length) {
+ // Grow the pool
+ HttpHeader[] newHeaderPool =
+ new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT];
+ for (int i = 0; i < nextHeader; i++) {
+ newHeaderPool[i] = headerPool[i];
+ }
+ headerPool = newHeaderPool;
+ }
+ if (headerPool[nextHeader] == null)
+ headerPool[nextHeader] = new HttpHeader();
+ return headerPool[nextHeader++];
+ }
+
+
+ /**
+ * Add a Header to the set of Headers associated with this Request.
+ *
+ * @param name The new header name
+ * @param value The new header value
+ * @deprecated Don't use
+ */
+ public void addHeader(String name, String value) {
+
+ if (nextHeader == headerPool.length) {
+ // Grow the pool
+ HttpHeader[] newHeaderPool =
+ new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT];
+ for (int i = 0; i < nextHeader; i++) {
+ newHeaderPool[i] = headerPool[i];
+ }
+ headerPool = newHeaderPool;
+ }
+ headerPool[nextHeader++] = new HttpHeader(name, value);
+
+ }
+
+
+ /**
+ * Return the first value of the specified header, if any; otherwise,
+ * return <code>null</code>
+ *
+ * @param header Header we want to retrieve
+ */
+ public HttpHeader getHeader(HttpHeader header) {
+
+ for (int i = 0; i < nextHeader; i++) {
+ if (headerPool[i].equals(header))
+ return headerPool[i];
+ }
+ return null;
+
+ }
+
+
+ /**
+ * Return the first value of the specified header, if any; otherwise,
+ * return <code>null</code>
+ *
+ * @param headerName Name of the requested header
+ */
+ public HttpHeader getHeader(char[] headerName) {
+
+ for (int i = 0; i < nextHeader; i++) {
+ if (headerPool[i].equals(headerName))
+ return headerPool[i];
+ }
+ return null;
+
+ }
+
+
// ------------------------------------------------- ServletRequest Methods
@@ -193,6 +316,64 @@
// --------------------------------------------- HttpServletRequest Methods
+
+
+ /**
+ * Return the first value of the specified header, if any; otherwise,
+ * return <code>null</code>
+ *
+ * @param name Name of the requested header
+ */
+ public String getHeader(String name) {
+
+ name = name.toLowerCase();
+ for (int i = 0; i < nextHeader; i++) {
+ if (headerPool[i].equals(name))
+ return new String(headerPool[i].value, 0,
+ headerPool[i].valueEnd);
+ }
+ return null;
+
+
+ }
+
+
+ /**
+ * Return all of the values of the specified header, if any; otherwise,
+ * return an empty enumeration.
+ *
+ * @param name Name of the requested header
+ */
+ public Enumeration getHeaders(String name) {
+
+ ArrayList tempArrayList = new ArrayList();
+ name = name.toLowerCase();
+ for (int i = 0; i < nextHeader; i++) {
+ if (headerPool[i].equals(name))
+ tempArrayList.add(new String(headerPool[i].value, 0,
+ headerPool[i].valueEnd));
+ }
+ return new Enumerator(tempArrayList);
+
+ }
+
+
+ /**
+ * Return the names of all headers received with this request.
+ */
+ public Enumeration getHeaderNames() {
+
+ ArrayList tempArrayList = new ArrayList();
+ for (int i = 0; i < nextHeader; i++) {
+ tempArrayList.add(new String(headerPool[i].name, 0,
+ headerPool[i].nameEnd));
+ }
+ return new Enumerator(tempArrayList);
+
+ }
+
+
+
}
1.2 +56 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestLine.java
Index: HttpRequestLine.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestLine.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpRequestLine.java 2000/11/17 03:30:43 1.1
+++ HttpRequestLine.java 2000/11/24 19:55:20 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestLine.java,v
1.1 2000/11/17 03:30:43 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/11/17 03:30:43 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestLine.java,v
1.2 2000/11/24 19:55:20 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/11/24 19:55:20 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
* HTTP request line enum type.
*
* @author Remy Maucherat
- * @version $Revision: 1.1 $ $Date: 2000/11/17 03:30:43 $
+ * @version $Revision: 1.2 $ $Date: 2000/11/24 19:55:20 $
*/
final class HttpRequestLine {
@@ -144,6 +144,58 @@
uriEnd = 0;
protocolEnd = 0;
+ }
+
+
+ /**
+ * Test if the uri includes the given char array.
+ */
+ public int indexOf(char[] buf) {
+ return indexOf(buf, buf.length);
+ }
+
+
+ /**
+ * Test if the value of the header includes the given char array.
+ */
+ public int indexOf(char[] buf, int end) {
+ char firstChar = buf[0];
+ int pos = 0;
+ while (pos < uriEnd) {
+ pos = indexOf(firstChar, pos);
+ if (pos == -1)
+ return -1;
+ if ((uriEnd - pos) < end)
+ return -1;
+ for (int i = 0; i < end; i++) {
+ if (uri[i + pos] != buf[i])
+ break;
+ if (i == (end-1))
+ return pos;
+ }
+ pos++;
+ }
+ return -1;
+ }
+
+
+ /**
+ * Test if the value of the header includes the given string.
+ */
+ public int indexOf(String str) {
+ return indexOf(str.toCharArray(), str.length());
+ }
+
+
+ /**
+ * Returns the index of a character in the value.
+ */
+ public int indexOf(char c, int start) {
+ for (int i=start; i<uriEnd; i++) {
+ if (uri[i] == c)
+ return i;
+ }
+ return -1;
}
1.1
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/DefaultHeaders.java
Index: DefaultHeaders.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/DefaultHeaders.java,v
1.1 2000/11/24 19:55:20 remm Exp $
* $Revision: 1.1 $
* $Date: 2000/11/24 19:55:20 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.connector.http;
/**
* HTTP default headers and header names.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $ $Date: 2000/11/24 19:55:20 $
*/
final class DefaultHeaders {
// -------------------------------------------------------------- Constants
static final char[] AUTHORIZATION_NAME = "authorization".toCharArray();
static final char[] ACCEPT_LANGUAGE_NAME = "accept-language".toCharArray();
static final char[] COOKIE_NAME = "cookie".toCharArray();
static final char[] CONTENT_LENGTH_NAME = "content-length".toCharArray();
static final char[] CONTENT_TYPE_NAME = "content-type".toCharArray();
static final char[] HOST_NAME = "host".toCharArray();
static final char[] CONNECTION_NAME = "connection".toCharArray();
static final char[] CONNECTION_CLOSE_VALUE = "close".toCharArray();
static final char[] EXPECT_NAME = "expect".toCharArray();
static final char[] EXPECT_100_VALUE = "100-continue".toCharArray();
static final char[] TRANSFER_ENCODING_NAME =
"transfer-encoding".toCharArray();
static final HttpHeader CONNECTION_CLOSE =
new HttpHeader("connection", "close");
static final HttpHeader EXPECT_CONTINUE =
new HttpHeader("expect", "100-continue");
static final HttpHeader TRANSFER_ENCODING_CHUNKED =
new HttpHeader("transfer-encoding", "chunked");
// ----------------------------------------------------------- Constructors
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Properties
// --------------------------------------------------------- Public Methods
// --------------------------------------------------------- Object Methods
}