001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027 028package org.apache.http.protocol; 029 030import java.nio.charset.Charset; 031 032import org.apache.http.Consts; 033 034/** 035 * Constants and static helpers related to the HTTP protocol. 036 * 037 * @since 4.0 038 */ 039public final class HTTP { 040 041 public static final int CR = 13; // <US-ASCII CR, carriage return (13)> 042 public static final int LF = 10; // <US-ASCII LF, linefeed (10)> 043 public static final int SP = 32; // <US-ASCII SP, space (32)> 044 public static final int HT = 9; // <US-ASCII HT, horizontal-tab (9)> 045 046 /** HTTP header definitions */ 047 public static final String TRANSFER_ENCODING = "Transfer-Encoding"; 048 public static final String CONTENT_LEN = "Content-Length"; 049 public static final String CONTENT_TYPE = "Content-Type"; 050 public static final String CONTENT_ENCODING = "Content-Encoding"; 051 public static final String EXPECT_DIRECTIVE = "Expect"; 052 public static final String CONN_DIRECTIVE = "Connection"; 053 public static final String TARGET_HOST = "Host"; 054 public static final String USER_AGENT = "User-Agent"; 055 public static final String DATE_HEADER = "Date"; 056 public static final String SERVER_HEADER = "Server"; 057 058 /** HTTP expectations */ 059 public static final String EXPECT_CONTINUE = "100-continue"; 060 061 /** HTTP connection control */ 062 public static final String CONN_CLOSE = "Close"; 063 public static final String CONN_KEEP_ALIVE = "Keep-Alive"; 064 065 /** Transfer encoding definitions */ 066 public static final String CHUNK_CODING = "chunked"; 067 public static final String IDENTITY_CODING = "identity"; 068 069 public static final Charset DEF_CONTENT_CHARSET = Consts.ISO_8859_1; 070 public static final Charset DEF_PROTOCOL_CHARSET = Consts.ASCII; 071 072 /** 073 * @deprecated (4.2) 074 */ 075 @Deprecated 076 public static final String UTF_8 = "UTF-8"; 077 078 /** 079 * @deprecated (4.2) 080 */ 081 @Deprecated 082 public static final String UTF_16 = "UTF-16"; 083 084 /** 085 * @deprecated (4.2) 086 */ 087 @Deprecated 088 public static final String US_ASCII = "US-ASCII"; 089 090 /** 091 * @deprecated (4.2) 092 */ 093 @Deprecated 094 public static final String ASCII = "ASCII"; 095 096 /** 097 * @deprecated (4.2) 098 */ 099 @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}