1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.jk.common;
19
20
21 /**
22 * Common class for the AJP Protocol values
23 */
24
25 public class AjpConstants {
26 // Prefix codes for message types from server to container
27 /**
28 * Message code for initial Request packet
29 */
30 public static final byte JK_AJP13_FORWARD_REQUEST = 2;
31 /**
32 * Message code for a request to shutdown Tomcat
33 */
34 public static final byte JK_AJP13_SHUTDOWN = 7;
35 /**
36 * Message code for a Ping request (obsolete)
37 */
38 public static final byte JK_AJP13_PING_REQUEST = 8;
39 /**
40 * Message code for a CPing request
41 */
42 public static final byte JK_AJP13_CPING_REQUEST = 10;
43
44 // Prefix codes for message types from container to server
45 /**
46 * Response code that the package is part of the Response body
47 */
48 public static final byte JK_AJP13_SEND_BODY_CHUNK = 3;
49 /**
50 * Response code that the package is the HTTP headers
51 */
52 public static final byte JK_AJP13_SEND_HEADERS = 4;
53 /**
54 * Response code for EOT
55 */
56 public static final byte JK_AJP13_END_RESPONSE = 5;
57 /**
58 * Response code to request the next Request body chunk
59 */
60 public static final byte JK_AJP13_GET_BODY_CHUNK = 6;
61 /**
62 * Response code to reply to a CPing
63 */
64 public static final byte JK_AJP13_CPONG_REPLY = 9;
65
66 // Integer codes for common response header strings
67 public static final int SC_RESP_CONTENT_TYPE = 0xA001;
68 public static final int SC_RESP_CONTENT_LANGUAGE = 0xA002;
69 public static final int SC_RESP_CONTENT_LENGTH = 0xA003;
70 public static final int SC_RESP_DATE = 0xA004;
71 public static final int SC_RESP_LAST_MODIFIED = 0xA005;
72 public static final int SC_RESP_LOCATION = 0xA006;
73 public static final int SC_RESP_SET_COOKIE = 0xA007;
74 public static final int SC_RESP_SET_COOKIE2 = 0xA008;
75 public static final int SC_RESP_SERVLET_ENGINE = 0xA009;
76 public static final int SC_RESP_STATUS = 0xA00A;
77 public static final int SC_RESP_WWW_AUTHENTICATE = 0xA00B;
78
79 // Integer codes for common (optional) request attribute names
80 public static final byte SC_A_CONTEXT = 1; // XXX Unused
81 public static final byte SC_A_SERVLET_PATH = 2; // XXX Unused
82 public static final byte SC_A_REMOTE_USER = 3;
83 public static final byte SC_A_AUTH_TYPE = 4;
84 public static final byte SC_A_QUERY_STRING = 5;
85 public static final byte SC_A_JVM_ROUTE = 6;
86 public static final byte SC_A_SSL_CERT = 7;
87 public static final byte SC_A_SSL_CIPHER = 8;
88 public static final byte SC_A_SSL_SESSION = 9;
89 public static final byte SC_A_SSL_KEYSIZE = 11;
90 public static final byte SC_A_SECRET = 12;
91 public static final byte SC_A_STORED_METHOD = 13;
92
93 // Used for attributes which are not in the list above
94 /**
95 * Request Attribute is passed as a String
96 */
97 public static final byte SC_A_REQ_ATTRIBUTE = 10;
98
99 /**
100 * Terminates list of attributes
101 */
102 public static final byte SC_A_ARE_DONE = (byte)0xFF;
103
104 /**
105 * Translates integer codes to names of HTTP methods
106 */
107 public static final String []methodTransArray = {
108 "OPTIONS",
109 "GET",
110 "HEAD",
111 "POST",
112 "PUT",
113 "DELETE",
114 "TRACE",
115 "PROPFIND",
116 "PROPPATCH",
117 "MKCOL",
118 "COPY",
119 "MOVE",
120 "LOCK",
121 "UNLOCK",
122 "ACL",
123 "REPORT",
124 "VERSION-CONTROL",
125 "CHECKIN",
126 "CHECKOUT",
127 "UNCHECKOUT",
128 "SEARCH",
129 "MKWORKSPACE",
130 "UPDATE",
131 "LABEL",
132 "MERGE",
133 "BASELINE-CONTROL",
134 "MKACTIVITY"
135 };
136
137 /**
138 * Request Method is passed as a String
139 */
140 public static final int SC_M_JK_STORED = (byte) 0xFF;
141
142 // id's for common request headers
143 public static final int SC_REQ_ACCEPT = 1;
144 public static final int SC_REQ_ACCEPT_CHARSET = 2;
145 public static final int SC_REQ_ACCEPT_ENCODING = 3;
146 public static final int SC_REQ_ACCEPT_LANGUAGE = 4;
147 public static final int SC_REQ_AUTHORIZATION = 5;
148 public static final int SC_REQ_CONNECTION = 6;
149 public static final int SC_REQ_CONTENT_TYPE = 7;
150 public static final int SC_REQ_CONTENT_LENGTH = 8;
151 public static final int SC_REQ_COOKIE = 9;
152 public static final int SC_REQ_COOKIE2 = 10;
153 public static final int SC_REQ_HOST = 11;
154 public static final int SC_REQ_PRAGMA = 12;
155 public static final int SC_REQ_REFERER = 13;
156 public static final int SC_REQ_USER_AGENT = 14;
157 // AJP14 new header
158 public static final byte SC_A_SSL_KEY_SIZE = 11; // XXX ???
159
160 /**
161 * Translates integer codes to request header names
162 */
163 public static final String []headerTransArray = {
164 "accept",
165 "accept-charset",
166 "accept-encoding",
167 "accept-language",
168 "authorization",
169 "connection",
170 "content-type",
171 "content-length",
172 "cookie",
173 "cookie2",
174 "host",
175 "pragma",
176 "referer",
177 "user-agent"
178 };
179 // Ajp13 specific - needs refactoring for the new model
180 /**
181 * Maximum Total byte size for a AJP packet
182 */
183 public static final int MAX_PACKET_SIZE=8192;
184 /**
185 * Size of basic packet header
186 */
187 public static final int H_SIZE=4;
188 /**
189 * Maximum size of data that can be sent in one packet
190 */
191 public static final int MAX_READ_SIZE = MAX_PACKET_SIZE - H_SIZE - 2;
192
193 }