View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.http.protocol;
29  
30  import java.nio.charset.Charset;
31  
32  import org.apache.http.Consts;
33  
34  /**
35   * Constants and static helpers related to the HTTP protocol.
36   *
37   * @since 4.0
38   */
39  public final class HTTP {
40  
41      public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
42      public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
43      public static final int SP = 32; // <US-ASCII SP, space (32)>
44      public static final int HT = 9;  // <US-ASCII HT, horizontal-tab (9)>
45  
46      /** HTTP header definitions */
47      public static final String TRANSFER_ENCODING = "Transfer-Encoding";
48      public static final String CONTENT_LEN  = "Content-Length";
49      public static final String CONTENT_TYPE = "Content-Type";
50      public static final String CONTENT_ENCODING = "Content-Encoding";
51      public static final String EXPECT_DIRECTIVE = "Expect";
52      public static final String CONN_DIRECTIVE = "Connection";
53      public static final String TARGET_HOST = "Host";
54      public static final String USER_AGENT = "User-Agent";
55      public static final String DATE_HEADER = "Date";
56      public static final String SERVER_HEADER = "Server";
57  
58      /** HTTP expectations */
59      public static final String EXPECT_CONTINUE = "100-continue";
60  
61      /** HTTP connection control */
62      public static final String CONN_CLOSE = "Close";
63      public static final String CONN_KEEP_ALIVE = "Keep-Alive";
64  
65      /** Transfer encoding definitions */
66      public static final String CHUNK_CODING = "chunked";
67      public static final String IDENTITY_CODING = "identity";
68  
69      public static final Charset DEF_CONTENT_CHARSET = Consts.ISO_8859_1;
70      public static final Charset DEF_PROTOCOL_CHARSET = Consts.ASCII;
71  
72      /**
73       * @deprecated (4.2)
74       */
75      @Deprecated
76      public static final String UTF_8 = "UTF-8";
77  
78      /**
79       * @deprecated (4.2)
80       */
81      @Deprecated
82      public static final String UTF_16 = "UTF-16";
83  
84      /**
85       * @deprecated (4.2)
86       */
87      @Deprecated
88      public static final String US_ASCII = "US-ASCII";
89  
90      /**
91       * @deprecated (4.2)
92       */
93      @Deprecated
94      public static final String ASCII = "ASCII";
95  
96      /**
97       * @deprecated (4.2)
98       */
99      @Deprecated
100     public static final String ISO_8859_1 = "ISO-8859-1";
101 
102     /**
103      * @deprecated (4.2)
104      */
105     @Deprecated
106     public static final String DEFAULT_CONTENT_CHARSET = ISO_8859_1;
107 
108     /**
109      * @deprecated (4.2)
110      */
111     @Deprecated
112     public static final String DEFAULT_PROTOCOL_CHARSET = US_ASCII;
113 
114     /**
115      * @deprecated (4.2)
116      */
117     @Deprecated
118     public final static String OCTET_STREAM_TYPE = "application/octet-stream";
119 
120     /**
121      * @deprecated (4.2)
122      */
123     @Deprecated
124     public final static String PLAIN_TEXT_TYPE = "text/plain";
125 
126     /**
127      * @deprecated (4.2)
128      */
129     @Deprecated
130     public final static String CHARSET_PARAM = "; charset=";
131 
132     /**
133      * @deprecated (4.2)
134      */
135     @Deprecated
136     public final static String DEFAULT_CONTENT_TYPE = OCTET_STREAM_TYPE;
137 
138     public static boolean isWhitespace(final char ch) {
139         return ch == SP || ch == HT || ch == CR || ch == LF;
140     }
141 
142     private HTTP() {
143     }
144 
145 }