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.coyote.http11;
019:
020: import org.apache.tomcat.util.buf.ByteChunk;
021:
022: /**
023: * Constants.
024: *
025: * @author Remy Maucherat
026: */
027: public final class Constants {
028:
029: // -------------------------------------------------------------- Constants
030:
031: /**
032: * Package name.
033: */
034: public static final String Package = "org.apache.coyote.http11";
035:
036: public static final int DEFAULT_CONNECTION_LINGER = -1;
037: public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
038: public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
039: public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
040: public static final boolean DEFAULT_TCP_NO_DELAY = true;
041:
042: /**
043: * CRLF.
044: */
045: public static final String CRLF = "\r\n";
046:
047: /**
048: * Server string.
049: */
050: public static final byte[] SERVER_BYTES = ByteChunk
051: .convertToBytes("Server: Apache-Coyote/1.1" + CRLF);
052:
053: /**
054: * CR.
055: */
056: public static final byte CR = (byte) '\r';
057:
058: /**
059: * LF.
060: */
061: public static final byte LF = (byte) '\n';
062:
063: /**
064: * SP.
065: */
066: public static final byte SP = (byte) ' ';
067:
068: /**
069: * HT.
070: */
071: public static final byte HT = (byte) '\t';
072:
073: /**
074: * COLON.
075: */
076: public static final byte COLON = (byte) ':';
077:
078: /**
079: * SEMI_COLON.
080: */
081: public static final byte SEMI_COLON = (byte) ';';
082:
083: /**
084: * 'A'.
085: */
086: public static final byte A = (byte) 'A';
087:
088: /**
089: * 'a'.
090: */
091: public static final byte a = (byte) 'a';
092:
093: /**
094: * 'Z'.
095: */
096: public static final byte Z = (byte) 'Z';
097:
098: /**
099: * '?'.
100: */
101: public static final byte QUESTION = (byte) '?';
102:
103: /**
104: * Lower case offset.
105: */
106: public static final byte LC_OFFSET = A - a;
107:
108: /**
109: * Default HTTP header buffer size.
110: */
111: public static final int DEFAULT_HTTP_HEADER_BUFFER_SIZE = 48 * 1024;
112:
113: /* Various constant "strings" */
114: public static final byte[] CRLF_BYTES = ByteChunk
115: .convertToBytes(CRLF);
116: public static final byte[] COLON_BYTES = ByteChunk
117: .convertToBytes(": ");
118: public static final String CONNECTION = "Connection";
119: public static final String CLOSE = "close";
120: public static final byte[] CLOSE_BYTES = ByteChunk
121: .convertToBytes(CLOSE);
122: public static final String KEEPALIVE = "keep-alive";
123: public static final byte[] KEEPALIVE_BYTES = ByteChunk
124: .convertToBytes(KEEPALIVE);
125: public static final String CHUNKED = "chunked";
126: public static final byte[] ACK_BYTES = ByteChunk
127: .convertToBytes("HTTP/1.1 100 Continue" + CRLF + CRLF);
128: public static final String TRANSFERENCODING = "Transfer-Encoding";
129: public static final byte[] _200_BYTES = ByteChunk
130: .convertToBytes("200");
131: public static final byte[] _400_BYTES = ByteChunk
132: .convertToBytes("400");
133: public static final byte[] _404_BYTES = ByteChunk
134: .convertToBytes("404");
135:
136: /**
137: * Identity filters (input and output).
138: */
139: public static final int IDENTITY_FILTER = 0;
140:
141: /**
142: * Chunked filters (input and output).
143: */
144: public static final int CHUNKED_FILTER = 1;
145:
146: /**
147: * Void filters (input and output).
148: */
149: public static final int VOID_FILTER = 2;
150:
151: /**
152: * GZIP filter (output).
153: */
154: public static final int GZIP_FILTER = 3;
155:
156: /**
157: * Buffered filter (input)
158: */
159: public static final int BUFFERED_FILTER = 3;
160:
161: /**
162: * HTTP/1.0.
163: */
164: public static final String HTTP_10 = "HTTP/1.0";
165:
166: /**
167: * HTTP/1.1.
168: */
169: public static final String HTTP_11 = "HTTP/1.1";
170: public static final byte[] HTTP_11_BYTES = ByteChunk
171: .convertToBytes(HTTP_11);
172:
173: /**
174: * GET.
175: */
176: public static final String GET = "GET";
177:
178: /**
179: * HEAD.
180: */
181: public static final String HEAD = "HEAD";
182:
183: /**
184: * POST.
185: */
186: public static final String POST = "POST";
187:
188: }
|