001/* 002 * Copyright (C) 2011 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package com.google.common.net; 016 017import com.google.common.annotations.Beta; 018import com.google.common.annotations.GwtCompatible; 019 020/** 021 * Contains constant definitions for the HTTP header field names. See: 022 * 023 * <ul> 024 * <li><a href="http://www.ietf.org/rfc/rfc2109.txt">RFC 2109</a> 025 * <li><a href="http://www.ietf.org/rfc/rfc2183.txt">RFC 2183</a> 026 * <li><a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> 027 * <li><a href="http://www.ietf.org/rfc/rfc2965.txt">RFC 2965</a> 028 * <li><a href="http://www.ietf.org/rfc/rfc5988.txt">RFC 5988</a> 029 * </ul> 030 * 031 * 032 * @author Kurt Alfred Kluever 033 * @since 11.0 034 */ 035@GwtCompatible 036public final class HttpHeaders { 037 private HttpHeaders() {} 038 039 // HTTP Request and Response header fields 040 041 /** The HTTP {@code Cache-Control} header field name. */ 042 public static final String CACHE_CONTROL = "Cache-Control"; 043 /** The HTTP {@code Content-Length} header field name. */ 044 public static final String CONTENT_LENGTH = "Content-Length"; 045 /** The HTTP {@code Content-Type} header field name. */ 046 public static final String CONTENT_TYPE = "Content-Type"; 047 /** The HTTP {@code Date} header field name. */ 048 public static final String DATE = "Date"; 049 /** The HTTP {@code Pragma} header field name. */ 050 public static final String PRAGMA = "Pragma"; 051 /** The HTTP {@code Via} header field name. */ 052 public static final String VIA = "Via"; 053 /** The HTTP {@code Warning} header field name. */ 054 public static final String WARNING = "Warning"; 055 056 // HTTP Request header fields 057 058 /** The HTTP {@code Accept} header field name. */ 059 public static final String ACCEPT = "Accept"; 060 /** The HTTP {@code Accept-Charset} header field name. */ 061 public static final String ACCEPT_CHARSET = "Accept-Charset"; 062 /** The HTTP {@code Accept-Encoding} header field name. */ 063 public static final String ACCEPT_ENCODING = "Accept-Encoding"; 064 /** The HTTP {@code Accept-Language} header field name. */ 065 public static final String ACCEPT_LANGUAGE = "Accept-Language"; 066 /** The HTTP {@code Access-Control-Request-Headers} header field name. */ 067 public static final String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; 068 /** The HTTP {@code Access-Control-Request-Method} header field name. */ 069 public static final String ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; 070 /** The HTTP {@code Authorization} header field name. */ 071 public static final String AUTHORIZATION = "Authorization"; 072 /** The HTTP {@code Connection} header field name. */ 073 public static final String CONNECTION = "Connection"; 074 /** The HTTP {@code Cookie} header field name. */ 075 public static final String COOKIE = "Cookie"; 076 /** The HTTP {@code Expect} header field name. */ 077 public static final String EXPECT = "Expect"; 078 /** The HTTP {@code From} header field name. */ 079 public static final String FROM = "From"; 080 /** 081 * The HTTP <a href="https://tools.ietf.org/html/rfc7239">{@code Forwarded}</a> header field name. 082 * 083 * @since 20.0 084 */ 085 public static final String FORWARDED = "Forwarded"; 086 /** 087 * The HTTP {@code Follow-Only-When-Prerender-Shown} header field name. 088 * 089 * @since 17.0 090 */ 091 @Beta 092 public static final String FOLLOW_ONLY_WHEN_PRERENDER_SHOWN = "Follow-Only-When-Prerender-Shown"; 093 /** The HTTP {@code Host} header field name. */ 094 public static final String HOST = "Host"; 095 /** 096 * The HTTP <a href="https://tools.ietf.org/html/rfc7540#section-3.2.1">{@code HTTP2-Settings} 097 * </a> header field name. 098 * 099 * @since 24.0 100 */ 101 public static final String HTTP2_SETTINGS = "HTTP2-Settings"; 102 /** The HTTP {@code If-Match} header field name. */ 103 public static final String IF_MATCH = "If-Match"; 104 /** The HTTP {@code If-Modified-Since} header field name. */ 105 public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; 106 /** The HTTP {@code If-None-Match} header field name. */ 107 public static final String IF_NONE_MATCH = "If-None-Match"; 108 /** The HTTP {@code If-Range} header field name. */ 109 public static final String IF_RANGE = "If-Range"; 110 /** The HTTP {@code If-Unmodified-Since} header field name. */ 111 public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; 112 /** The HTTP {@code Last-Event-ID} header field name. */ 113 public static final String LAST_EVENT_ID = "Last-Event-ID"; 114 /** The HTTP {@code Max-Forwards} header field name. */ 115 public static final String MAX_FORWARDS = "Max-Forwards"; 116 /** The HTTP {@code Origin} header field name. */ 117 public static final String ORIGIN = "Origin"; 118 /** The HTTP {@code Proxy-Authorization} header field name. */ 119 public static final String PROXY_AUTHORIZATION = "Proxy-Authorization"; 120 /** The HTTP {@code Range} header field name. */ 121 public static final String RANGE = "Range"; 122 /** The HTTP {@code Referer} header field name. */ 123 public static final String REFERER = "Referer"; 124 /** 125 * The HTTP <a href="https://www.w3.org/TR/referrer-policy/">{@code Referrer-Policy}</a> header 126 * field name. 127 * 128 * @since 23.4 129 */ 130 public static final String REFERRER_POLICY = "Referrer-Policy"; 131 132 /** 133 * Values for the <a href="https://www.w3.org/TR/referrer-policy/">{@code Referrer-Policy}</a> 134 * header. 135 * 136 * @since 23.4 137 */ 138 public static final class ReferrerPolicyValues { 139 private ReferrerPolicyValues() {} 140 141 public static final String NO_REFERRER = "no-referrer"; 142 public static final String NO_REFFERER_WHEN_DOWNGRADE = "no-referrer-when-downgrade"; 143 public static final String SAME_ORIGIN = "same-origin"; 144 public static final String ORIGIN = "origin"; 145 public static final String STRICT_ORIGIN = "strict-origin"; 146 public static final String ORIGIN_WHEN_CROSS_ORIGIN = "origin-when-cross-origin"; 147 public static final String STRICT_ORIGIN_WHEN_CROSS_ORIGIN = "strict-origin-when-cross-origin"; 148 public static final String UNSAFE_URL = "unsafe-url"; 149 } 150 151 /** 152 * The HTTP <a href="https://www.w3.org/TR/service-workers/#update-algorithm">{@code 153 * Service-Worker}</a> header field name. 154 */ 155 public static final String SERVICE_WORKER = "Service-Worker"; 156 /** The HTTP {@code TE} header field name. */ 157 public static final String TE = "TE"; 158 /** The HTTP {@code Upgrade} header field name. */ 159 public static final String UPGRADE = "Upgrade"; 160 /** The HTTP {@code User-Agent} header field name. */ 161 public static final String USER_AGENT = "User-Agent"; 162 163 // HTTP Response header fields 164 165 /** The HTTP {@code Accept-Ranges} header field name. */ 166 public static final String ACCEPT_RANGES = "Accept-Ranges"; 167 /** The HTTP {@code Access-Control-Allow-Headers} header field name. */ 168 public static final String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; 169 /** The HTTP {@code Access-Control-Allow-Methods} header field name. */ 170 public static final String ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"; 171 /** The HTTP {@code Access-Control-Allow-Origin} header field name. */ 172 public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; 173 /** The HTTP {@code Access-Control-Allow-Credentials} header field name. */ 174 public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; 175 /** The HTTP {@code Access-Control-Expose-Headers} header field name. */ 176 public static final String ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"; 177 /** The HTTP {@code Access-Control-Max-Age} header field name. */ 178 public static final String ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"; 179 /** The HTTP {@code Age} header field name. */ 180 public static final String AGE = "Age"; 181 /** The HTTP {@code Allow} header field name. */ 182 public static final String ALLOW = "Allow"; 183 /** The HTTP {@code Content-Disposition} header field name. */ 184 public static final String CONTENT_DISPOSITION = "Content-Disposition"; 185 /** The HTTP {@code Content-Encoding} header field name. */ 186 public static final String CONTENT_ENCODING = "Content-Encoding"; 187 /** The HTTP {@code Content-Language} header field name. */ 188 public static final String CONTENT_LANGUAGE = "Content-Language"; 189 /** The HTTP {@code Content-Location} header field name. */ 190 public static final String CONTENT_LOCATION = "Content-Location"; 191 /** The HTTP {@code Content-MD5} header field name. */ 192 public static final String CONTENT_MD5 = "Content-MD5"; 193 /** The HTTP {@code Content-Range} header field name. */ 194 public static final String CONTENT_RANGE = "Content-Range"; 195 /** 196 * The HTTP <a href="http://w3.org/TR/CSP/#content-security-policy-header-field">{@code 197 * Content-Security-Policy}</a> header field name. 198 * 199 * @since 15.0 200 */ 201 public static final String CONTENT_SECURITY_POLICY = "Content-Security-Policy"; 202 /** 203 * The HTTP <a href="http://w3.org/TR/CSP/#content-security-policy-report-only-header-field"> 204 * {@code Content-Security-Policy-Report-Only}</a> header field name. 205 * 206 * @since 15.0 207 */ 208 public static final String CONTENT_SECURITY_POLICY_REPORT_ONLY = 209 "Content-Security-Policy-Report-Only"; 210 /** 211 * The HTTP nonstandard {@code X-Content-Security-Policy} header field name. It was introduced in 212 * <a href="https://www.w3.org/TR/2011/WD-CSP-20111129/">CSP v.1</a> and used by the Firefox until 213 * version 23 and the Internet Explorer version 10. Please, use {@link #CONTENT_SECURITY_POLICY} 214 * to pass the CSP. 215 * 216 * @since 20.0 217 */ 218 public static final String X_CONTENT_SECURITY_POLICY = "X-Content-Security-Policy"; 219 /** 220 * The HTTP nonstandard {@code X-Content-Security-Policy-Report-Only} header field name. It was 221 * introduced in <a href="https://www.w3.org/TR/2011/WD-CSP-20111129/">CSP v.1</a> and used by the 222 * Firefox until version 23 and the Internet Explorer version 10. Please, use {@link 223 * #CONTENT_SECURITY_POLICY_REPORT_ONLY} to pass the CSP. 224 * 225 * @since 20.0 226 */ 227 public static final String X_CONTENT_SECURITY_POLICY_REPORT_ONLY = 228 "X-Content-Security-Policy-Report-Only"; 229 /** 230 * The HTTP nonstandard {@code X-WebKit-CSP} header field name. It was introduced in <a 231 * href="https://www.w3.org/TR/2011/WD-CSP-20111129/">CSP v.1</a> and used by the Chrome until 232 * version 25. Please, use {@link #CONTENT_SECURITY_POLICY} to pass the CSP. 233 * 234 * @since 20.0 235 */ 236 public static final String X_WEBKIT_CSP = "X-WebKit-CSP"; 237 /** 238 * The HTTP nonstandard {@code X-WebKit-CSP-Report-Only} header field name. It was introduced in 239 * <a href="https://www.w3.org/TR/2011/WD-CSP-20111129/">CSP v.1</a> and used by the Chrome until 240 * version 25. Please, use {@link #CONTENT_SECURITY_POLICY_REPORT_ONLY} to pass the CSP. 241 * 242 * @since 20.0 243 */ 244 public static final String X_WEBKIT_CSP_REPORT_ONLY = "X-WebKit-CSP-Report-Only"; 245 /** The HTTP {@code ETag} header field name. */ 246 public static final String ETAG = "ETag"; 247 /** The HTTP {@code Expires} header field name. */ 248 public static final String EXPIRES = "Expires"; 249 /** The HTTP {@code Last-Modified} header field name. */ 250 public static final String LAST_MODIFIED = "Last-Modified"; 251 /** The HTTP {@code Link} header field name. */ 252 public static final String LINK = "Link"; 253 /** The HTTP {@code Location} header field name. */ 254 public static final String LOCATION = "Location"; 255 /** The HTTP {@code P3P} header field name. Limited browser support. */ 256 public static final String P3P = "P3P"; 257 /** The HTTP {@code Proxy-Authenticate} header field name. */ 258 public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate"; 259 /** The HTTP {@code Refresh} header field name. Non-standard header supported by most browsers. */ 260 public static final String REFRESH = "Refresh"; 261 /** The HTTP {@code Retry-After} header field name. */ 262 public static final String RETRY_AFTER = "Retry-After"; 263 /** The HTTP {@code Server} header field name. */ 264 public static final String SERVER = "Server"; 265 /** 266 * The HTTP <a href="https://www.w3.org/TR/server-timing/">{@code Server-Timing}</a> header field 267 * name. 268 * 269 * @since 23.6 270 */ 271 public static final String SERVER_TIMING = "Server-Timing"; 272 /** 273 * The HTTP <a href="https://www.w3.org/TR/service-workers/#update-algorithm">{@code 274 * Service-Worker-Allowed}</a> header field name. 275 * 276 * @since 20.0 277 */ 278 public static final String SERVICE_WORKER_ALLOWED = "Service-Worker-Allowed"; 279 /** The HTTP {@code Set-Cookie} header field name. */ 280 public static final String SET_COOKIE = "Set-Cookie"; 281 /** The HTTP {@code Set-Cookie2} header field name. */ 282 public static final String SET_COOKIE2 = "Set-Cookie2"; 283 /** 284 * The HTTP <a href="http://tools.ietf.org/html/rfc6797#section-6.1">{@code 285 * Strict-Transport-Security}</a> header field name. 286 * 287 * @since 15.0 288 */ 289 public static final String STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security"; 290 /** 291 * The HTTP <a href="http://www.w3.org/TR/resource-timing/#cross-origin-resources">{@code 292 * Timing-Allow-Origin}</a> header field name. 293 * 294 * @since 15.0 295 */ 296 public static final String TIMING_ALLOW_ORIGIN = "Timing-Allow-Origin"; 297 /** The HTTP {@code Trailer} header field name. */ 298 public static final String TRAILER = "Trailer"; 299 /** The HTTP {@code Transfer-Encoding} header field name. */ 300 public static final String TRANSFER_ENCODING = "Transfer-Encoding"; 301 /** The HTTP {@code Vary} header field name. */ 302 public static final String VARY = "Vary"; 303 /** The HTTP {@code WWW-Authenticate} header field name. */ 304 public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; 305 306 // Common, non-standard HTTP header fields 307 308 /** The HTTP {@code DNT} header field name. */ 309 public static final String DNT = "DNT"; 310 /** The HTTP {@code X-Content-Type-Options} header field name. */ 311 public static final String X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options"; 312 /** The HTTP {@code X-Do-Not-Track} header field name. */ 313 public static final String X_DO_NOT_TRACK = "X-Do-Not-Track"; 314 /** The HTTP {@code X-Forwarded-For} header field name (superseded by {@code Forwarded}). */ 315 public static final String X_FORWARDED_FOR = "X-Forwarded-For"; 316 /** The HTTP {@code X-Forwarded-Proto} header field name. */ 317 public static final String X_FORWARDED_PROTO = "X-Forwarded-Proto"; 318 /** 319 * The HTTP <a href="http://goo.gl/lQirAH">{@code X-Forwarded-Host}</a> header field name. 320 * 321 * @since 20.0 322 */ 323 public static final String X_FORWARDED_HOST = "X-Forwarded-Host"; 324 /** 325 * The HTTP <a href="http://goo.gl/YtV2at">{@code X-Forwarded-Port}</a> header field name. 326 * 327 * @since 20.0 328 */ 329 public static final String X_FORWARDED_PORT = "X-Forwarded-Port"; 330 /** The HTTP {@code X-Frame-Options} header field name. */ 331 public static final String X_FRAME_OPTIONS = "X-Frame-Options"; 332 /** The HTTP {@code X-Powered-By} header field name. */ 333 public static final String X_POWERED_BY = "X-Powered-By"; 334 /** 335 * The HTTP <a href="http://tools.ietf.org/html/draft-evans-palmer-key-pinning">{@code 336 * Public-Key-Pins}</a> header field name. 337 * 338 * @since 15.0 339 */ 340 @Beta public static final String PUBLIC_KEY_PINS = "Public-Key-Pins"; 341 /** 342 * The HTTP <a href="http://tools.ietf.org/html/draft-evans-palmer-key-pinning">{@code 343 * Public-Key-Pins-Report-Only}</a> header field name. 344 * 345 * @since 15.0 346 */ 347 @Beta public static final String PUBLIC_KEY_PINS_REPORT_ONLY = "Public-Key-Pins-Report-Only"; 348 /** The HTTP {@code X-Requested-With} header field name. */ 349 public static final String X_REQUESTED_WITH = "X-Requested-With"; 350 /** The HTTP {@code X-User-IP} header field name. */ 351 public static final String X_USER_IP = "X-User-IP"; 352 /** 353 * The HTTP <a href="https://goo.gl/VKpXxa">{@code X-Download-Options}</a> header field name. 354 * 355 * <p>When the new X-Download-Options header is present with the value {@code noopen}, the user is 356 * prevented from opening a file download directly; instead, they must first save the file 357 * locally. 358 * 359 * @since 24.1 360 */ 361 @Beta 362 public static final String X_DOWNLOAD_OPTIONS = "X-Download-Options"; 363 /** The HTTP {@code X-XSS-Protection} header field name. */ 364 public static final String X_XSS_PROTECTION = "X-XSS-Protection"; 365 /** 366 * The HTTP <a 367 * href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control">{@code 368 * X-DNS-Prefetch-Control}</a> header controls DNS prefetch behavior. Value can be "on" or "off". 369 * By default, DNS prefetching is "on" for HTTP pages and "off" for HTTPS pages. 370 */ 371 public static final String X_DNS_PREFETCH_CONTROL = "X-DNS-Prefetch-Control"; 372 /** 373 * The HTTP <a href="http://html.spec.whatwg.org/multipage/semantics.html#hyperlink-auditing"> 374 * {@code Ping-From}</a> header field name. 375 * 376 * @since 19.0 377 */ 378 public static final String PING_FROM = "Ping-From"; 379 /** 380 * The HTTP <a href="http://html.spec.whatwg.org/multipage/semantics.html#hyperlink-auditing"> 381 * {@code Ping-To}</a> header field name. 382 * 383 * @since 19.0 384 */ 385 public static final String PING_TO = "Ping-To"; 386 387 /** 388 * The HTTP <a href="https://github.com/mikewest/sec-metadata">{@code Sec-Metadata}</a> header 389 * field name. 390 * 391 * @since 26.0 392 */ 393 public static final String SEC_METADATA = "Sec-Metadata"; 394 /** 395 * The HTTP <a href="https://tools.ietf.org/html/draft-ietf-tokbind-https">{@code 396 * Sec-Token-Binding}</a> header field name. 397 * 398 * @since 25.1 399 */ 400 public static final String SEC_TOKEN_BINDING = "Sec-Token-Binding"; 401 /** 402 * The HTTP <a href="https://tools.ietf.org/html/draft-ietf-tokbind-ttrp">{@code 403 * Sec-Provided-Token-Binding-ID}</a> header field name. 404 * 405 * @since 25.1 406 */ 407 public static final String SEC_PROVIDED_TOKEN_BINDING_ID = "Sec-Provided-Token-Binding-ID"; 408 /** 409 * The HTTP <a href="https://tools.ietf.org/html/draft-ietf-tokbind-ttrp">{@code 410 * Sec-Referred-Token-Binding-ID}</a> header field name. 411 * 412 * @since 25.1 413 */ 414 public static final String SEC_REFERRED_TOKEN_BINDING_ID = "Sec-Referred-Token-Binding-ID"; 415}