/*
* Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core.http;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.util.AsciiString;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.MultiMap;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
Contains a bunch of useful HTTP headers stuff:
- methods for creating
MultiMap
instances
- often used Header names
- method to create optimized
CharSequence
which can be used as header name and value
Author: Norman Maurer
/**
* Contains a bunch of useful HTTP headers stuff:
*
* <ul>
* <li>methods for creating {@link MultiMap} instances</li>
* <li>often used Header names</li>
* <li>method to create optimized {@link CharSequence} which can be used as header name and value</li>
* </ul>
*
* @author <a href="mailto:nmaurer@redhat.com">Norman Maurer</a>
*/
@VertxGen
public interface HttpHeaders {
JVM system property that disables HTTP headers validation, don't use this in production. /** JVM system property that disables HTTP headers validation, don't use this in production. */
String DISABLE_HTTP_HEADERS_VALIDATION_PROP_NAME = "vertx.disableHttpHeadersValidation";
Constant that disables HTTP headers validation, this is a constant so the JIT can eliminate validation code. /** Constant that disables HTTP headers validation, this is a constant so the JIT can eliminate validation code. */
boolean DISABLE_HTTP_HEADERS_VALIDATION = Boolean.getBoolean(DISABLE_HTTP_HEADERS_VALIDATION_PROP_NAME);
Accept header name
/**
* Accept header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT = HttpHeaderNames.ACCEPT;
Accept-Charset header name
/**
* Accept-Charset header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT_CHARSET = HttpHeaderNames.ACCEPT_CHARSET;
Accept-Encoding header name
/**
* Accept-Encoding header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT_ENCODING = HttpHeaderNames.ACCEPT_ENCODING;
Accept-Language header name
/**
* Accept-Language header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT_LANGUAGE = HttpHeaderNames.ACCEPT_LANGUAGE;
Accept-Ranges header name
/**
* Accept-Ranges header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT_RANGES = HttpHeaderNames.ACCEPT_RANGES;
Accept-Patch header name
/**
* Accept-Patch header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCEPT_PATCH = HttpHeaderNames.ACCEPT_PATCH;
Access-Control-Allow-Credentials header name
/**
* Access-Control-Allow-Credentials header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_ALLOW_CREDENTIALS = HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS;
Access-Control-Allow-Headers header name
/**
* Access-Control-Allow-Headers header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_ALLOW_HEADERS = HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS;
Access-Control-Allow-Methods header name
/**
* Access-Control-Allow-Methods header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_ALLOW_METHODS = HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS;
Access-Control-Allow-Origin header name
/**
* Access-Control-Allow-Origin header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_ALLOW_ORIGIN = HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN;
Access-Control-Expose-Headers header name
/**
* Access-Control-Expose-Headers header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_EXPOSE_HEADERS = HttpHeaderNames.ACCESS_CONTROL_EXPOSE_HEADERS;
Access-Control-Max-Age header name
/**
* Access-Control-Max-Age header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_MAX_AGE = HttpHeaderNames.ACCESS_CONTROL_MAX_AGE;
Access-Control-Request-Headers header name
/**
* Access-Control-Request-Headers header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_REQUEST_HEADERS = HttpHeaderNames.ACCESS_CONTROL_REQUEST_HEADERS;
Access-Control-Request-Method header name
/**
* Access-Control-Request-Method header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ACCESS_CONTROL_REQUEST_METHOD = HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD;
Age header name
/**
* Age header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence AGE = HttpHeaderNames.AGE;
Allow header name
/**
* Allow header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ALLOW = HttpHeaderNames.ALLOW;
Authorization header name
/**
* Authorization header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence AUTHORIZATION = HttpHeaderNames.AUTHORIZATION;
Cache-Control header name
/**
* Cache-Control header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CACHE_CONTROL = HttpHeaderNames.CACHE_CONTROL;
Connection header name
/**
* Connection header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONNECTION = HttpHeaderNames.CONNECTION;
Content-Base header name
/**
* Content-Base header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_BASE = HttpHeaderNames.CONTENT_BASE;
Content-Disposition header name
/**
* Content-Disposition header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_DISPOSITION = HttpHeaderNames.CONTENT_DISPOSITION;
Content-Encoding header name
/**
* Content-Encoding header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_ENCODING = HttpHeaderNames.CONTENT_ENCODING;
Content-Language header name
/**
* Content-Language header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_LANGUAGE = HttpHeaderNames.CONTENT_LANGUAGE;
Content-Length header name
/**
* Content-Length header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_LENGTH = HttpHeaderNames.CONTENT_LENGTH;
Content-Location header name
/**
* Content-Location header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_LOCATION = HttpHeaderNames.CONTENT_LOCATION;
Content-Transfer-Encoding header name
/**
* Content-Transfer-Encoding header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_TRANSFER_ENCODING = HttpHeaderNames.CONTENT_TRANSFER_ENCODING;
Content-MD5 header name
/**
* Content-MD5 header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_MD5 = HttpHeaderNames.CONTENT_MD5;
Content-Rage header name
/**
* Content-Rage header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_RANGE = HttpHeaderNames.CONTENT_RANGE;
Content-Type header name
/**
* Content-Type header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTENT_TYPE = HttpHeaderNames.CONTENT_TYPE;
Content-Cookie header name
/**
* Content-Cookie header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence COOKIE = HttpHeaderNames.COOKIE;
Date header name
/**
* Date header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence DATE = HttpHeaderNames.DATE;
Etag header name
/**
* Etag header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ETAG = HttpHeaderNames.ETAG;
Expect header name
/**
* Expect header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence EXPECT = HttpHeaderNames.EXPECT;
Expires header name
/**
* Expires header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence EXPIRES = HttpHeaderNames.EXPIRES;
From header name
/**
* From header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence FROM = HttpHeaderNames.FROM;
Host header name
/**
* Host header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence HOST = HttpHeaderNames.HOST;
If-Match header name
/**
* If-Match header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence IF_MATCH = HttpHeaderNames.IF_MATCH;
If-Modified-Since header name
/**
* If-Modified-Since header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence IF_MODIFIED_SINCE = HttpHeaderNames.IF_MODIFIED_SINCE;
If-None-Match header name
/**
* If-None-Match header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence IF_NONE_MATCH = HttpHeaderNames.IF_NONE_MATCH;
Last-Modified header name
/**
* Last-Modified header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence LAST_MODIFIED = HttpHeaderNames.LAST_MODIFIED;
Location header name
/**
* Location header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence LOCATION = HttpHeaderNames.LOCATION;
Origin header name
/**
* Origin header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence ORIGIN = HttpHeaderNames.ORIGIN;
Proxy-Authenticate header name
/**
* Proxy-Authenticate header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence PROXY_AUTHENTICATE = HttpHeaderNames.PROXY_AUTHENTICATE;
Proxy-Authorization header name
/**
* Proxy-Authorization header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence PROXY_AUTHORIZATION = HttpHeaderNames.PROXY_AUTHORIZATION;
Referer header name
/**
* Referer header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence REFERER = HttpHeaderNames.REFERER;
Retry-After header name
/**
* Retry-After header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence RETRY_AFTER = HttpHeaderNames.RETRY_AFTER;
Server header name
/**
* Server header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence SERVER = HttpHeaderNames.SERVER;
Transfer-Encoding header name
/**
* Transfer-Encoding header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence TRANSFER_ENCODING = HttpHeaderNames.TRANSFER_ENCODING;
User-Agent header name
/**
* User-Agent header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence USER_AGENT = HttpHeaderNames.USER_AGENT;
Set-Cookie header name
/**
* Set-Cookie header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence SET_COOKIE = HttpHeaderNames.SET_COOKIE;
application/x-www-form-urlencoded header value
/**
* application/x-www-form-urlencoded header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence APPLICATION_X_WWW_FORM_URLENCODED = HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED;
chunked header value
/**
* chunked header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CHUNKED = HttpHeaderValues.CHUNKED;
close header value
/**
* close header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CLOSE = HttpHeaderValues.CLOSE;
100-continue header value
/**
* 100-continue header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence CONTINUE = HttpHeaderValues.CONTINUE;
identity header value
/**
* identity header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence IDENTITY = HttpHeaderValues.IDENTITY;
keep-alive header value
/**
* keep-alive header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence KEEP_ALIVE = HttpHeaderValues.KEEP_ALIVE;
Upgrade header value
/**
* Upgrade header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence UPGRADE = HttpHeaderValues.UPGRADE;
WebSocket header value
/**
* WebSocket header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence WEBSOCKET = HttpHeaderValues.WEBSOCKET;
deflate,gzip header value
/**
* deflate,gzip header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence DEFLATE_GZIP = createOptimized("deflate, gzip");
text/html header value
/**
* text/html header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence TEXT_HTML = createOptimized("text/html");
GET header value
/**
* GET header value
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence GET = createOptimized("GET");
Vary header name
/**
* Vary header name
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
CharSequence VARY = createOptimized("vary");
Create an optimized CharSequence
which can be used as header name or value. This should be used if you expect to use it multiple times liked for example adding the same header name or value for multiple responses or requests. /**
* Create an optimized {@link CharSequence} which can be used as header name or value.
* This should be used if you expect to use it multiple times liked for example adding the same header name or value
* for multiple responses or requests.
*/
@GenIgnore(GenIgnore.PERMITTED_TYPE)
static CharSequence createOptimized(String value) {
return new AsciiString(value);
}
static MultiMap headers() {
return HeadersMultiMap.httpHeaders();
}
static MultiMap set(String name, String value) {
return HeadersMultiMap.httpHeaders().set(name, value);
}
@GenIgnore(GenIgnore.PERMITTED_TYPE)
static MultiMap set(CharSequence name, CharSequence value) {
return HeadersMultiMap.httpHeaders().set(name, value);
}
}