KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > coyote > ajp > Constants


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.coyote.ajp;
19
20 import org.apache.tomcat.util.buf.ByteChunk;
21
22
23 /**
24  * Constants.
25  *
26  * @author Remy Maucherat
27  */

28 public final class Constants {
29
30
31     // -------------------------------------------------------------- Constants
32

33
34     /**
35      * Package name.
36      */

37     public static final String JavaDoc Package = "org.apache.coyote.ajp";
38
39     public static final int DEFAULT_CONNECTION_LINGER = -1;
40     public static final int DEFAULT_CONNECTION_TIMEOUT = -1;
41     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
42     public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
43     public static final boolean DEFAULT_TCP_NO_DELAY = true;
44
45     // Prefix codes for message types from server to container
46
public static final byte JK_AJP13_FORWARD_REQUEST = 2;
47     public static final byte JK_AJP13_SHUTDOWN = 7;
48     public static final byte JK_AJP13_PING_REQUEST = 8;
49     public static final byte JK_AJP13_CPING_REQUEST = 10;
50
51     // Prefix codes for message types from container to server
52
public static final byte JK_AJP13_SEND_BODY_CHUNK = 3;
53     public static final byte JK_AJP13_SEND_HEADERS = 4;
54     public static final byte JK_AJP13_END_RESPONSE = 5;
55     public static final byte JK_AJP13_GET_BODY_CHUNK = 6;
56     public static final byte JK_AJP13_CPONG_REPLY = 9;
57
58     // Integer codes for common response header strings
59
public static final int SC_RESP_CONTENT_TYPE = 0xA001;
60     public static final int SC_RESP_CONTENT_LANGUAGE = 0xA002;
61     public static final int SC_RESP_CONTENT_LENGTH = 0xA003;
62     public static final int SC_RESP_DATE = 0xA004;
63     public static final int SC_RESP_LAST_MODIFIED = 0xA005;
64     public static final int SC_RESP_LOCATION = 0xA006;
65     public static final int SC_RESP_SET_COOKIE = 0xA007;
66     public static final int SC_RESP_SET_COOKIE2 = 0xA008;
67     public static final int SC_RESP_SERVLET_ENGINE = 0xA009;
68     public static final int SC_RESP_STATUS = 0xA00A;
69     public static final int SC_RESP_WWW_AUTHENTICATE = 0xA00B;
70
71     // Integer codes for common (optional) request attribute names
72
public static final byte SC_A_CONTEXT = 1; // XXX Unused
73
public static final byte SC_A_SERVLET_PATH = 2; // XXX Unused
74
public static final byte SC_A_REMOTE_USER = 3;
75     public static final byte SC_A_AUTH_TYPE = 4;
76     public static final byte SC_A_QUERY_STRING = 5;
77     public static final byte SC_A_JVM_ROUTE = 6;
78     public static final byte SC_A_SSL_CERT = 7;
79     public static final byte SC_A_SSL_CIPHER = 8;
80     public static final byte SC_A_SSL_SESSION = 9;
81     public static final byte SC_A_SSL_KEYSIZE = 11;
82     public static final byte SC_A_SECRET = 12;
83     public static final byte SC_A_STORED_METHOD = 13;
84
85     // Used for attributes which are not in the list above
86
public static final byte SC_A_REQ_ATTRIBUTE = 10;
87
88     // Terminates list of attributes
89
public static final byte SC_A_ARE_DONE = (byte)0xFF;
90
91     // Ajp13 specific - needs refactoring for the new model
92

93     /**
94      * Default maximum total byte size for a AJP packet
95      */

96     public static final int MAX_PACKET_SIZE = 8192;
97     /**
98      * Size of basic packet header
99      */

100     public static final int H_SIZE = 4;
101
102     /**
103      * Size of the header metadata
104      */

105     public static final int READ_HEAD_LEN = 6;
106     public static final int SEND_HEAD_LEN = 8;
107
108     /**
109      * Default maximum size of data that can be sent in one packet
110      */

111     public static final int MAX_READ_SIZE = MAX_PACKET_SIZE - READ_HEAD_LEN;
112     public static final int MAX_SEND_SIZE = MAX_PACKET_SIZE - SEND_HEAD_LEN;
113
114     // Translates integer codes to names of HTTP methods
115
public static final String JavaDoc []methodTransArray = {
116             "OPTIONS",
117             "GET",
118             "HEAD",
119             "POST",
120             "PUT",
121             "DELETE",
122             "TRACE",
123             "PROPFIND",
124             "PROPPATCH",
125             "MKCOL",
126             "COPY",
127             "MOVE",
128             "LOCK",
129             "UNLOCK",
130             "ACL",
131             "REPORT",
132             "VERSION-CONTROL",
133             "CHECKIN",
134             "CHECKOUT",
135             "UNCHECKOUT",
136             "SEARCH",
137             "MKWORKSPACE",
138             "UPDATE",
139             "LABEL",
140             "MERGE",
141             "BASELINE-CONTROL",
142             "MKACTIVITY"
143     };
144     public static final int SC_M_JK_STORED = (byte) 0xFF;
145
146     // id's for common request headers
147
public static final int SC_REQ_ACCEPT = 1;
148     public static final int SC_REQ_ACCEPT_CHARSET = 2;
149     public static final int SC_REQ_ACCEPT_ENCODING = 3;
150     public static final int SC_REQ_ACCEPT_LANGUAGE = 4;
151     public static final int SC_REQ_AUTHORIZATION = 5;
152     public static final int SC_REQ_CONNECTION = 6;
153     public static final int SC_REQ_CONTENT_TYPE = 7;
154     public static final int SC_REQ_CONTENT_LENGTH = 8;
155     public static final int SC_REQ_COOKIE = 9;
156     public static final int SC_REQ_COOKIE2 = 10;
157     public static final int SC_REQ_HOST = 11;
158     public static final int SC_REQ_PRAGMA = 12;
159     public static final int SC_REQ_REFERER = 13;
160     public static final int SC_REQ_USER_AGENT = 14;
161     // AJP14 new header
162
public static final byte SC_A_SSL_KEY_SIZE = 11; // XXX ???
163

164     // Translates integer codes to request header names
165
public static final String JavaDoc []headerTransArray = {
166             "accept",
167             "accept-charset",
168             "accept-encoding",
169             "accept-language",
170             "authorization",
171             "connection",
172             "content-type",
173             "content-length",
174             "cookie",
175             "cookie2",
176             "host",
177             "pragma",
178             "referer",
179             "user-agent"
180     };
181
182
183     /**
184      * CRLF.
185      */

186     public static final String JavaDoc CRLF = "\r\n";
187
188
189     /**
190      * Server string.
191      */

192     public static final byte[] SERVER_BYTES =
193         ByteChunk.convertToBytes("Server: Apache-Coyote/1.1" + CRLF);
194
195
196     /**
197      * CR.
198      */

199     public static final byte CR = (byte) '\r';
200
201
202     /**
203      * LF.
204      */

205     public static final byte LF = (byte) '\n';
206
207
208     /**
209      * SP.
210      */

211     public static final byte SP = (byte) ' ';
212
213
214     /**
215      * HT.
216      */

217     public static final byte HT = (byte) '\t';
218
219
220     /**
221      * COLON.
222      */

223     public static final byte COLON = (byte) ':';
224
225
226     /**
227      * 'A'.
228      */

229     public static final byte A = (byte) 'A';
230
231
232     /**
233      * 'a'.
234      */

235     public static final byte a = (byte) 'a';
236
237
238     /**
239      * 'Z'.
240      */

241     public static final byte Z = (byte) 'Z';
242
243
244     /**
245      * '?'.
246      */

247     public static final byte QUESTION = (byte) '?';
248
249
250     /**
251      * Lower case offset.
252      */

253     public static final byte LC_OFFSET = A - a;
254
255
256     /**
257      * Default HTTP header buffer size.
258      */

259     public static final int DEFAULT_HTTP_HEADER_BUFFER_SIZE = 48 * 1024;
260
261
262     /* Various constant "strings" */
263     public static final byte[] CRLF_BYTES = ByteChunk.convertToBytes(CRLF);
264     public static final byte[] COLON_BYTES = ByteChunk.convertToBytes(": ");
265     public static final String JavaDoc CONNECTION = "Connection";
266     public static final String JavaDoc CLOSE = "close";
267     public static final byte[] CLOSE_BYTES =
268         ByteChunk.convertToBytes(CLOSE);
269     public static final String JavaDoc KEEPALIVE = "keep-alive";
270     public static final byte[] KEEPALIVE_BYTES =
271         ByteChunk.convertToBytes(KEEPALIVE);
272     public static final String JavaDoc CHUNKED = "chunked";
273     public static final byte[] ACK_BYTES =
274         ByteChunk.convertToBytes("HTTP/1.1 100 Continue" + CRLF + CRLF);
275     public static final String JavaDoc TRANSFERENCODING = "Transfer-Encoding";
276     public static final byte[] _200_BYTES =
277         ByteChunk.convertToBytes("200");
278     public static final byte[] _400_BYTES =
279         ByteChunk.convertToBytes("400");
280     public static final byte[] _404_BYTES =
281         ByteChunk.convertToBytes("404");
282
283
284     /**
285      * Identity filters (input and output).
286      */

287     public static final int IDENTITY_FILTER = 0;
288
289
290     /**
291      * Chunked filters (input and output).
292      */

293     public static final int CHUNKED_FILTER = 1;
294
295
296     /**
297      * Void filters (input and output).
298      */

299     public static final int VOID_FILTER = 2;
300
301
302     /**
303      * GZIP filter (output).
304      */

305     public static final int GZIP_FILTER = 3;
306
307
308     /**
309      * Buffered filter (input)
310      */

311     public static final int BUFFERED_FILTER = 3;
312
313
314     /**
315      * HTTP/1.0.
316      */

317     public static final String JavaDoc HTTP_10 = "HTTP/1.0";
318
319
320     /**
321      * HTTP/1.1.
322      */

323     public static final String JavaDoc HTTP_11 = "HTTP/1.1";
324     public static final byte[] HTTP_11_BYTES =
325         ByteChunk.convertToBytes(HTTP_11);
326
327
328     /**
329      * GET.
330      */

331     public static final String JavaDoc GET = "GET";
332
333
334     /**
335      * HEAD.
336      */

337     public static final String JavaDoc HEAD = "HEAD";
338
339
340     /**
341      * POST.
342      */

343     public static final String JavaDoc POST = "POST";
344
345
346 }
347
Popular Tags