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       * @deprecated (4.2)
79       */
80      @Deprecated
81      public static final String UTF_16 = "UTF-16";
82      /**
83       * @deprecated (4.2)
84       */
85      @Deprecated
86      public static final String US_ASCII = "US-ASCII";
87      /**
88       * @deprecated (4.2)
89       */
90      @Deprecated
91      public static final String ASCII = "ASCII";
92      /**
93       * @deprecated (4.2)
94       */
95      @Deprecated
96      public static final String ISO_8859_1 = "ISO-8859-1";
97      /**
98       * @deprecated (4.2)
99       */
100     @Deprecated
101     public static final String DEFAULT_CONTENT_CHARSET = ISO_8859_1;
102     /**
103      * @deprecated (4.2)
104      */
105     @Deprecated
106     public static final String DEFAULT_PROTOCOL_CHARSET = US_ASCII;
107     /**
108      * @deprecated (4.2)
109      */
110     @Deprecated
111     public final static String OCTET_STREAM_TYPE = "application/octet-stream";
112     /**
113      * @deprecated (4.2)
114      */
115     @Deprecated
116     public final static String PLAIN_TEXT_TYPE = "text/plain";
117     /**
118      * @deprecated (4.2)
119      */
120     @Deprecated
121     public final static String CHARSET_PARAM = "; charset=";
122     /**
123      * @deprecated (4.2)
124      */
125     @Deprecated
126     public final static String DEFAULT_CONTENT_TYPE = OCTET_STREAM_TYPE;
127 
128     public static boolean isWhitespace(char ch) {
129         return ch == SP || ch == HT || ch == CR || ch == LF;
130     }
131 
132     private HTTP() {
133     }
134 
135 }