001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jk.common;
019:
020: /**
021: * Common class for the AJP Protocol values
022: */
023:
024: public class AjpConstants {
025: // Prefix codes for message types from server to container
026: /**
027: * Message code for initial Request packet
028: */
029: public static final byte JK_AJP13_FORWARD_REQUEST = 2;
030: /**
031: * Message code for a request to shutdown Tomcat
032: */
033: public static final byte JK_AJP13_SHUTDOWN = 7;
034: /**
035: * Message code for a Ping request (obsolete)
036: */
037: public static final byte JK_AJP13_PING_REQUEST = 8;
038: /**
039: * Message code for a CPing request
040: */
041: public static final byte JK_AJP13_CPING_REQUEST = 10;
042:
043: // Prefix codes for message types from container to server
044: /**
045: * Response code that the package is part of the Response body
046: */
047: public static final byte JK_AJP13_SEND_BODY_CHUNK = 3;
048: /**
049: * Response code that the package is the HTTP headers
050: */
051: public static final byte JK_AJP13_SEND_HEADERS = 4;
052: /**
053: * Response code for EOT
054: */
055: public static final byte JK_AJP13_END_RESPONSE = 5;
056: /**
057: * Response code to request the next Request body chunk
058: */
059: public static final byte JK_AJP13_GET_BODY_CHUNK = 6;
060: /**
061: * Response code to reply to a CPing
062: */
063: public static final byte JK_AJP13_CPONG_REPLY = 9;
064:
065: // Integer codes for common response header strings
066: public static final int SC_RESP_CONTENT_TYPE = 0xA001;
067: public static final int SC_RESP_CONTENT_LANGUAGE = 0xA002;
068: public static final int SC_RESP_CONTENT_LENGTH = 0xA003;
069: public static final int SC_RESP_DATE = 0xA004;
070: public static final int SC_RESP_LAST_MODIFIED = 0xA005;
071: public static final int SC_RESP_LOCATION = 0xA006;
072: public static final int SC_RESP_SET_COOKIE = 0xA007;
073: public static final int SC_RESP_SET_COOKIE2 = 0xA008;
074: public static final int SC_RESP_SERVLET_ENGINE = 0xA009;
075: public static final int SC_RESP_STATUS = 0xA00A;
076: public static final int SC_RESP_WWW_AUTHENTICATE = 0xA00B;
077:
078: // Integer codes for common (optional) request attribute names
079: public static final byte SC_A_CONTEXT = 1; // XXX Unused
080: public static final byte SC_A_SERVLET_PATH = 2; // XXX Unused
081: public static final byte SC_A_REMOTE_USER = 3;
082: public static final byte SC_A_AUTH_TYPE = 4;
083: public static final byte SC_A_QUERY_STRING = 5;
084: public static final byte SC_A_JVM_ROUTE = 6;
085: public static final byte SC_A_SSL_CERT = 7;
086: public static final byte SC_A_SSL_CIPHER = 8;
087: public static final byte SC_A_SSL_SESSION = 9;
088: public static final byte SC_A_SSL_KEYSIZE = 11;
089: public static final byte SC_A_SECRET = 12;
090: public static final byte SC_A_STORED_METHOD = 13;
091:
092: // Used for attributes which are not in the list above
093: /**
094: * Request Attribute is passed as a String
095: */
096: public static final byte SC_A_REQ_ATTRIBUTE = 10;
097:
098: /**
099: * Terminates list of attributes
100: */
101: public static final byte SC_A_ARE_DONE = (byte) 0xFF;
102:
103: /**
104: * Translates integer codes to names of HTTP methods
105: */
106: public static final String[] methodTransArray = { "OPTIONS", "GET",
107: "HEAD", "POST", "PUT", "DELETE", "TRACE", "PROPFIND",
108: "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK",
109: "ACL", "REPORT", "VERSION-CONTROL", "CHECKIN", "CHECKOUT",
110: "UNCHECKOUT", "SEARCH", "MKWORKSPACE", "UPDATE", "LABEL",
111: "MERGE", "BASELINE-CONTROL", "MKACTIVITY" };
112:
113: /**
114: * Request Method is passed as a String
115: */
116: public static final int SC_M_JK_STORED = (byte) 0xFF;
117:
118: // id's for common request headers
119: public static final int SC_REQ_ACCEPT = 1;
120: public static final int SC_REQ_ACCEPT_CHARSET = 2;
121: public static final int SC_REQ_ACCEPT_ENCODING = 3;
122: public static final int SC_REQ_ACCEPT_LANGUAGE = 4;
123: public static final int SC_REQ_AUTHORIZATION = 5;
124: public static final int SC_REQ_CONNECTION = 6;
125: public static final int SC_REQ_CONTENT_TYPE = 7;
126: public static final int SC_REQ_CONTENT_LENGTH = 8;
127: public static final int SC_REQ_COOKIE = 9;
128: public static final int SC_REQ_COOKIE2 = 10;
129: public static final int SC_REQ_HOST = 11;
130: public static final int SC_REQ_PRAGMA = 12;
131: public static final int SC_REQ_REFERER = 13;
132: public static final int SC_REQ_USER_AGENT = 14;
133: // AJP14 new header
134: public static final byte SC_A_SSL_KEY_SIZE = 11; // XXX ???
135:
136: /**
137: * Translates integer codes to request header names
138: */
139: public static final String[] headerTransArray = { "accept",
140: "accept-charset", "accept-encoding", "accept-language",
141: "authorization", "connection", "content-type",
142: "content-length", "cookie", "cookie2", "host", "pragma",
143: "referer", "user-agent" };
144: // Ajp13 specific - needs refactoring for the new model
145: /**
146: * Maximum Total byte size for a AJP packet
147: */
148: public static final int MAX_PACKET_SIZE = 8192;
149: /**
150: * Size of basic packet header
151: */
152: public static final int H_SIZE = 4;
153: /**
154: * Maximum size of data that can be sent in one packet
155: */
156: public static final int MAX_READ_SIZE = MAX_PACKET_SIZE - H_SIZE
157: - 2;
158:
159: }
|