comparison src/org/eclipse/jetty/http/HttpHeaderValues.java @ 1020:6be43ef1eb96

HttpHeaderValues uses StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 22:24:41 -0600
parents 74b9daf2826c
children 3718afd99988
comparison
equal deleted inserted replaced
1019:f126d30e04a4 1020:6be43ef1eb96
16 // ======================================================================== 16 // ========================================================================
17 // 17 //
18 18
19 package org.eclipse.jetty.http; 19 package org.eclipse.jetty.http;
20 20
21 import org.eclipse.jetty.io.Buffer; 21 import org.eclipse.jetty.io.StringCache;
22 import org.eclipse.jetty.io.BufferCache;
23 import org.eclipse.jetty.io.ByteArrayBuffer;
24 22
25 /** 23 /**
26 * Cached HTTP Header values. 24 * Cached HTTP Header values.
27 * This class caches the conversion of common HTTP Header values to and from {@link ByteArrayBuffer} instances.
28 * The resource "/org/eclipse/jetty/useragents" is checked for a list of common user agents, so that repeated 25 * The resource "/org/eclipse/jetty/useragents" is checked for a list of common user agents, so that repeated
29 * creation of strings for these agents can be avoided. 26 * creation of strings for these agents can be avoided.
30 * 27 *
31 * 28 *
32 */ 29 */
33 public class HttpHeaderValues extends BufferCache 30 public final class HttpHeaderValues
34 { 31 {
35 public final static String 32 public final static String
36 CLOSE="close", 33 CLOSE="close",
37 CHUNKED="chunked", 34 CHUNKED="chunked",
38 GZIP="gzip", 35 GZIP="gzip",
56 TE_ORDINAL=8, 53 TE_ORDINAL=8,
57 BYTES_ORDINAL=9, 54 BYTES_ORDINAL=9,
58 NO_CACHE_ORDINAL=10, 55 NO_CACHE_ORDINAL=10,
59 UPGRADE_ORDINAL=11; 56 UPGRADE_ORDINAL=11;
60 57
61 public final static HttpHeaderValues CACHE = new HttpHeaderValues(); 58 public final static StringCache CACHE = new StringCache();
62 59
63 public final static Buffer 60 public final static byte[]
64 CLOSE_BUFFER=CACHE.add(CLOSE,CLOSE_ORDINAL), 61 CLOSE_BYTES=CACHE.add(CLOSE,CLOSE_ORDINAL),
65 CHUNKED_BUFFER=CACHE.add(CHUNKED,CHUNKED_ORDINAL), 62 CHUNKED_BYTES=CACHE.add(CHUNKED,CHUNKED_ORDINAL),
66 GZIP_BUFFER=CACHE.add(GZIP,GZIP_ORDINAL), 63 GZIP_BYTES=CACHE.add(GZIP,GZIP_ORDINAL),
67 IDENTITY_BUFFER=CACHE.add(IDENTITY,IDENTITY_ORDINAL), 64 IDENTITY_BYTES=CACHE.add(IDENTITY,IDENTITY_ORDINAL),
68 KEEP_ALIVE_BUFFER=CACHE.add(KEEP_ALIVE,KEEP_ALIVE_ORDINAL), 65 KEEP_ALIVE_BYTES=CACHE.add(KEEP_ALIVE,KEEP_ALIVE_ORDINAL),
69 CONTINUE_BUFFER=CACHE.add(CONTINUE, CONTINUE_ORDINAL), 66 CONTINUE_BYTES=CACHE.add(CONTINUE, CONTINUE_ORDINAL),
70 PROCESSING_BUFFER=CACHE.add(PROCESSING, PROCESSING_ORDINAL), 67 PROCESSING_BYTES=CACHE.add(PROCESSING, PROCESSING_ORDINAL),
71 TE_BUFFER=CACHE.add(TE,TE_ORDINAL), 68 TE_BYTES=CACHE.add(TE,TE_ORDINAL),
72 BYTES_BUFFER=CACHE.add(BYTES,BYTES_ORDINAL), 69 BYTES_BYTES=CACHE.add(BYTES,BYTES_ORDINAL),
73 NO_CACHE_BUFFER=CACHE.add(NO_CACHE,NO_CACHE_ORDINAL), 70 NO_CACHE_BYTES=CACHE.add(NO_CACHE,NO_CACHE_ORDINAL),
74 UPGRADE_BUFFER=CACHE.add(UPGRADE,UPGRADE_ORDINAL); 71 UPGRADE_BYTES=CACHE.add(UPGRADE,UPGRADE_ORDINAL);
75 72
76 73
77 public static boolean hasKnownValues(int httpHeaderOrdinal) 74 public static boolean hasKnownValues(int httpHeaderOrdinal)
78 { 75 {
79 switch(httpHeaderOrdinal) 76 switch(httpHeaderOrdinal)