package io.undertow.util;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URLDecoder;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public final class {
private () {
}
public static final String = "Accept";
public static final String = "Accept-Charset";
public static final String = "Accept-Encoding";
public static final String = "Accept-Language";
public static final String = "Accept-Ranges";
public static final String = "Age";
public static final String = "Allow";
public static final String = "Authentication-Info";
public static final String = "Authorization";
public static final String = "Cache-Control";
public static final String = "Cookie";
public static final String = "Cookie2";
public static final String = "Connection";
public static final String = "Content-Disposition";
public static final String = "Content-Encoding";
public static final String = "Content-Language";
public static final String = "Content-Length";
public static final String = "Content-Location";
public static final String = "Content-MD5";
public static final String = "Content-Range";
public static final String = "Content-Security-Policy";
public static final String = "Content-Type";
public static final String = "Date";
public static final String = "ETag";
public static final String = "Expect";
public static final String = "Expires";
public static final String = "Forwarded";
public static final String = "From";
public static final String = "Host";
public static final String = "If-Match";
public static final String = "If-Modified-Since";
public static final String = "If-None-Match";
public static final String = "If-Range";
public static final String = "If-Unmodified-Since";
public static final String = "Last-Modified";
public static final String = "Location";
public static final String = "Max-Forwards";
public static final String = "Origin";
public static final String = "Pragma";
public static final String = "Proxy-Authenticate";
public static final String = "Proxy-Authorization";
public static final String = "Range";
public static final String = "Referer";
public static final String = "Referrer-Policy";
public static final String = "Refresh";
public static final String = "Retry-After";
public static final String = "Sec-WebSocket-Accept";
public static final String = "Sec-WebSocket-Extensions";
public static final String = "Sec-WebSocket-Key";
public static final String = "Sec-WebSocket-Key1";
public static final String = "Sec-WebSocket-Key2";
public static final String = "Sec-WebSocket-Location";
public static final String = "Sec-WebSocket-Origin";
public static final String = "Sec-WebSocket-Protocol";
public static final String = "Sec-WebSocket-Version";
public static final String = "Server";
public static final String = "Servlet-Engine";
public static final String = "Set-Cookie";
public static final String = "Set-Cookie2";
public static final String = "SSL_CLIENT_CERT";
public static final String = "SSL_CIPHER";
public static final String = "SSL_SESSION_ID";
public static final String = "SSL_CIPHER_USEKEYSIZE";
public static final String = "Status";
public static final String = "Strict-Transport-Security";
public static final String = "TE";
public static final String = "Trailer";
public static final String = "Transfer-Encoding";
public static final String = "Upgrade";
public static final String = "User-Agent";
public static final String = "Vary";
public static final String = "Via";
public static final String = "Warning";
public static final String = "WWW-Authenticate";
public static final String = "X-Content-Type-Options";
public static final String = "X-Disable-Push";
public static final String = "X-Forwarded-For";
public static final String = "X-Forwarded-Proto";
public static final String = "X-Forwarded-Host";
public static final String = "X-Forwarded-Port";
public static final String = "X-Forwarded-Server";
public static final String = "X-Frame-Options";
public static final String = "X-Xss-Protection";
public static final HttpString = new HttpString(ACCEPT_STRING, 1);
public static final HttpString = new HttpString(ACCEPT_CHARSET_STRING, 2);
public static final HttpString = new HttpString(ACCEPT_ENCODING_STRING, 3);
public static final HttpString = new HttpString(ACCEPT_LANGUAGE_STRING, 4);
public static final HttpString = new HttpString(ACCEPT_RANGES_STRING, 5);
public static final HttpString = new HttpString(AGE_STRING, 6);
public static final HttpString = new HttpString(ALLOW_STRING, 7);
public static final HttpString = new HttpString(AUTHENTICATION_INFO_STRING, 8);
public static final HttpString = new HttpString(AUTHORIZATION_STRING, 9);
public static final HttpString = new HttpString(CACHE_CONTROL_STRING, 10);
public static final HttpString = new HttpString(CONNECTION_STRING, 11);
public static final HttpString = new HttpString(CONTENT_DISPOSITION_STRING, 12);
public static final HttpString = new HttpString(CONTENT_ENCODING_STRING, 13);
public static final HttpString = new HttpString(CONTENT_LANGUAGE_STRING, 14);
public static final HttpString = new HttpString(CONTENT_LENGTH_STRING, 15);
public static final HttpString = new HttpString(CONTENT_LOCATION_STRING, 16);
public static final HttpString = new HttpString(CONTENT_MD5_STRING, 17);
public static final HttpString = new HttpString(CONTENT_RANGE_STRING, 18);
public static final HttpString = new HttpString(CONTENT_SECURITY_POLICY_STRING, 19);
public static final HttpString = new HttpString(CONTENT_TYPE_STRING, 20);
public static final HttpString = new HttpString(COOKIE_STRING, 21);
public static final HttpString = new HttpString(COOKIE2_STRING, 22);
public static final HttpString = new HttpString(DATE_STRING, 23);
public static final HttpString = new HttpString(ETAG_STRING, 24);
public static final HttpString = new HttpString(EXPECT_STRING, 25);
public static final HttpString = new HttpString(EXPIRES_STRING, 26);
public static final HttpString = new HttpString(FORWARDED_STRING, 27);
public static final HttpString = new HttpString(FROM_STRING, 28);
public static final HttpString = new HttpString(HOST_STRING, 29);
public static final HttpString = new HttpString(IF_MATCH_STRING, 30);
public static final HttpString = new HttpString(IF_MODIFIED_SINCE_STRING, 31);
public static final HttpString = new HttpString(IF_NONE_MATCH_STRING, 32);
public static final HttpString = new HttpString(IF_RANGE_STRING, 33);
public static final HttpString = new HttpString(IF_UNMODIFIED_SINCE_STRING, 34);
public static final HttpString = new HttpString(LAST_MODIFIED_STRING, 35);
public static final HttpString = new HttpString(LOCATION_STRING, 36);
public static final HttpString = new HttpString(MAX_FORWARDS_STRING, 37);
public static final HttpString = new HttpString(ORIGIN_STRING, 38);
public static final HttpString = new HttpString(PRAGMA_STRING, 39);
public static final HttpString = new HttpString(PROXY_AUTHENTICATE_STRING, 40);
public static final HttpString = new HttpString(PROXY_AUTHORIZATION_STRING, 41);
public static final HttpString = new HttpString(RANGE_STRING, 42);
public static final HttpString = new HttpString(REFERER_STRING, 43);
public static final HttpString = new HttpString(REFERRER_POLICY_STRING, 44);
public static final HttpString = new HttpString(REFRESH_STRING, 45);
public static final HttpString = new HttpString(RETRY_AFTER_STRING, 46);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_ACCEPT_STRING, 47);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_EXTENSIONS_STRING, 48);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_KEY_STRING, 49);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_KEY1_STRING, 50);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_KEY2_STRING, 51);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_LOCATION_STRING, 52);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_ORIGIN_STRING, 53);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_PROTOCOL_STRING, 54);
public static final HttpString = new HttpString(SEC_WEB_SOCKET_VERSION_STRING, 55);
public static final HttpString = new HttpString(SERVER_STRING, 56);
public static final HttpString = new HttpString(SERVLET_ENGINE_STRING, 57);
public static final HttpString = new HttpString(SET_COOKIE_STRING, 58);
public static final HttpString = new HttpString(SET_COOKIE2_STRING, 59);
public static final HttpString = new HttpString(SSL_CIPHER_STRING, 60);
public static final HttpString = new HttpString(SSL_CIPHER_USEKEYSIZE_STRING, 61);
public static final HttpString = new HttpString(SSL_CLIENT_CERT_STRING, 62);
public static final HttpString = new HttpString(SSL_SESSION_ID_STRING, 63);
public static final HttpString = new HttpString(STATUS_STRING, 64);
public static final HttpString = new HttpString(STRICT_TRANSPORT_SECURITY_STRING, 65);
public static final HttpString = new HttpString(TE_STRING, 66);
public static final HttpString = new HttpString(TRAILER_STRING, 67);
public static final HttpString = new HttpString(TRANSFER_ENCODING_STRING, 68);
public static final HttpString = new HttpString(UPGRADE_STRING, 69);
public static final HttpString = new HttpString(USER_AGENT_STRING, 70);
public static final HttpString = new HttpString(VARY_STRING, 71);
public static final HttpString = new HttpString(VIA_STRING, 72);
public static final HttpString = new HttpString(WARNING_STRING, 73);
public static final HttpString = new HttpString(WWW_AUTHENTICATE_STRING, 74);
public static final HttpString = new HttpString(X_CONTENT_TYPE_OPTIONS_STRING, 75);
public static final HttpString = new HttpString(X_DISABLE_PUSH_STRING, 76);
public static final HttpString = new HttpString(X_FORWARDED_FOR_STRING, 77);
public static final HttpString = new HttpString(X_FORWARDED_HOST_STRING, 78);
public static final HttpString = new HttpString(X_FORWARDED_PORT_STRING, 79);
public static final HttpString = new HttpString(X_FORWARDED_PROTO_STRING, 80);
public static final HttpString = new HttpString(X_FORWARDED_SERVER_STRING, 81);
public static final HttpString = new HttpString(X_FRAME_OPTIONS_STRING, 82);
public static final HttpString = new HttpString(X_XSS_PROTECTION_STRING, 83);
public static final HttpString = new HttpString("compress");
public static final HttpString = new HttpString("x-compress");
public static final HttpString = new HttpString("deflate");
public static final HttpString = new HttpString("identity");
public static final HttpString = new HttpString("gzip");
public static final HttpString = new HttpString("x-gzip");
public static final HttpString = new HttpString("chunked");
public static final HttpString = new HttpString("keep-alive");
public static final HttpString = new HttpString("close");
public static final String = "Content-Transfer-Encoding";
public static final HttpString = new HttpString(CONTENT_TRANSFER_ENCODING_STRING);
public static final HttpString = new HttpString("Basic");
public static final HttpString = new HttpString("Digest");
public static final HttpString = new HttpString("Negotiate");
public static final HttpString = new HttpString("algorithm");
public static final HttpString = new HttpString("auth-param");
public static final HttpString = new HttpString("cnonce");
public static final HttpString DOMAIN = new HttpString("domain");
public static final HttpString = new HttpString("nextnonce");
public static final HttpString = new HttpString("nonce");
public static final HttpString = new HttpString("nc");
public static final HttpString = new HttpString("opaque");
public static final HttpString = new HttpString("qop");
public static final HttpString = new HttpString("realm");
public static final HttpString = new HttpString("response");
public static final HttpString = new HttpString("rspauth");
public static final HttpString = new HttpString("stale");
public static final HttpString = new HttpString("uri");
public static final HttpString = new HttpString("username");
private static final Map<String, HttpString> ;
static {
Map<String, HttpString> map = AccessController.doPrivileged(new PrivilegedAction<Map<String, HttpString>>() {
@Override
public Map<String, HttpString> () {
Map<String, HttpString> map = new HashMap<>();
Field[] fields = Headers.class.getDeclaredFields();
for(Field field : fields) {
if(Modifier.isStatic(field.getModifiers()) && field.getType() == HttpString.class) {
field.setAccessible(true);
try {
HttpString result = (HttpString) field.get(null);
map.put(result.toString(), result);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
return map;
}
});
HTTP_STRING_MAP = Collections.unmodifiableMap(map);
}
public static HttpString (String string) {
return HTTP_STRING_MAP.get(string);
}
@Deprecated
public static String (final String header, final String key) {
int pos = header.indexOf(' ' + key + '=');
if (pos == -1) {
if(!header.startsWith(key + '=')) {
return null;
}
pos = 0;
} else {
pos++;
}
int end;
int start = pos + key.length() + 1;
for (end = start; end < header.length(); ++end) {
char c = header.charAt(end);
if (c == ' ' || c == '\t' || c == ';') {
break;
}
}
return header.substring(start, end);
}
public static String (final String header, final String key) {
int keypos = 0;
int pos = -1;
boolean whiteSpace = true;
boolean inQuotes = false;
for (int i = 0; i < header.length() - 1; ++i) {
char c = header.charAt(i);
if (inQuotes) {
if (c == '"') {
inQuotes = false;
}
} else {
if (key.charAt(keypos) == c && (whiteSpace || keypos > 0)) {
keypos++;
whiteSpace = false;
} else if (c == '"') {
keypos = 0;
inQuotes = true;
whiteSpace = false;
} else {
keypos = 0;
whiteSpace = c == ' ' || c == ';' || c == '\t';
}
if (keypos == key.length()) {
if (header.charAt(i + 1) == '=') {
pos = i + 2;
break;
} else {
keypos = 0;
}
}
}
}
if (pos == -1) {
return null;
}
int end;
int start = pos;
if (header.charAt(start) == '"') {
start++;
for (end = start; end < header.length(); ++end) {
char c = header.charAt(end);
if (c == '"') {
break;
}
}
return header.substring(start, end);
} else {
for (end = start; end < header.length(); ++end) {
char c = header.charAt(end);
if (c == ' ' || c == '\t' || c == ';') {
break;
}
}
return header.substring(start, end);
}
}
public static String (final String header, final String key) {
String value = extractQuotedValueFromHeader(header, key);
if (value != null) {
return value;
}
value = extractQuotedValueFromHeader(header , key + "*");
if(value != null) {
int characterSetDelimiter = value.indexOf('\'');
int languageDelimiter = value.lastIndexOf('\'', characterSetDelimiter + 1);
String characterSet = value.substring(0, characterSetDelimiter);
try {
String fileNameURLEncoded = value.substring(languageDelimiter + 1);
return URLDecoder.decode(fileNameURLEncoded, characterSet);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return null;
}
}