1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.spdy;
17
18 import org.jboss.netty.buffer.ChannelBuffer;
19
20 final class SpdyCodecUtil {
21
22 static final int SPDY_MIN_VERSION = 2;
23 static final int SPDY_MAX_VERSION = 3;
24
25 static final int SPDY_HEADER_TYPE_OFFSET = 2;
26 static final int SPDY_HEADER_FLAGS_OFFSET = 4;
27 static final int SPDY_HEADER_LENGTH_OFFSET = 5;
28 static final int SPDY_HEADER_SIZE = 8;
29
30 static final int SPDY_MAX_LENGTH = 0xFFFFFF;
31
32 static final byte SPDY_DATA_FLAG_FIN = 0x01;
33
34 static final int SPDY_SYN_STREAM_FRAME = 1;
35 static final int SPDY_SYN_REPLY_FRAME = 2;
36 static final int SPDY_RST_STREAM_FRAME = 3;
37 static final int SPDY_SETTINGS_FRAME = 4;
38 static final int SPDY_NOOP_FRAME = 5;
39 static final int SPDY_PING_FRAME = 6;
40 static final int SPDY_GOAWAY_FRAME = 7;
41 static final int SPDY_HEADERS_FRAME = 8;
42 static final int SPDY_WINDOW_UPDATE_FRAME = 9;
43 static final int SPDY_CREDENTIAL_FRAME = 10;
44
45 static final byte SPDY_FLAG_FIN = 0x01;
46 static final byte SPDY_FLAG_UNIDIRECTIONAL = 0x02;
47
48 static final byte SPDY_SETTINGS_CLEAR = 0x01;
49 static final byte SPDY_SETTINGS_PERSIST_VALUE = 0x01;
50 static final byte SPDY_SETTINGS_PERSISTED = 0x02;
51
52 static final int SPDY_SETTINGS_MAX_ID = 0xFFFFFF;
53
54 static final int SPDY_MAX_NV_LENGTH = 0xFFFF;
55
56
57 static final byte[] SPDY_DICT = {
58 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69,
59 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68,
60 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70,
61 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70,
62 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65,
63 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05,
64 0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00,
65 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00,
66 0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70,
67 0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,
68 0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63,
69 0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,
70 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f,
71 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c,
72 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00,
73 0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70,
74 0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73,
75 0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00,
76 0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77,
77 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68,
78 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f,
79 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63,
80 0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72,
81 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f,
82 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
83 0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74,
84 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65,
85 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74,
86 0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,
87 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10,
88 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
89 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
90 0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74,
91 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67,
92 0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f,
93 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f,
94 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00,
95 0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
96 0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00,
97 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
98 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00,
99 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
100 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00,
101 0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00,
102 0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00,
103 0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74,
104 0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69,
105 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66,
106 0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68,
107 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69,
108 0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00,
109 0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f,
110 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73,
111 0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d,
112 0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d,
113 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00,
114 0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67,
115 0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d,
116 0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69,
117 0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65,
118 0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74,
119 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65,
120 0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63,
121 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00,
122 0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72,
123 0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00,
124 0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00,
125 0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79,
126 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74,
127 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00,
128 0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61,
129 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61,
130 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05,
131 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00,
132 0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72,
133 0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72,
134 0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00,
135 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65,
136 0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00,
137 0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c,
138 0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72,
139 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65,
140 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00,
141 0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61,
142 0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73,
143 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74,
144 0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79,
145 0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00,
146 0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69,
147 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77,
148 0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,
149 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00,
150 0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
151 0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00,
152 0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
153 0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30,
154 0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76,
155 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00,
156 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31,
157 0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72,
158 0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62,
159 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73,
160 0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69,
161 0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65,
162 0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00,
163 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69,
164 0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32,
165 0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35,
166 0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30,
167 0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33,
168 0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37,
169 0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30,
170 0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34,
171 0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31,
172 0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31,
173 0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34,
174 0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34,
175 0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e,
176 0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f,
177 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65,
178 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61,
179 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20,
180 0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65,
181 0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f,
182 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d,
183 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34,
184 0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52,
185 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30,
186 0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68,
187 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30,
188 0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64,
189 0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e,
190 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64,
191 0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65,
192 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72,
193 0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f,
194 0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74,
195 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65,
196 0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20,
197 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20,
198 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61,
199 0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46,
200 0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41,
201 0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a,
202 0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41,
203 0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20,
204 0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20,
205 0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30,
206 0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e,
207 0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57,
208 0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c,
209 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61,
210 0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20,
211 0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b,
212 0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f,
213 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61,
214 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69,
215 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67,
216 0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67,
217 0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,
218 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,
219 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,
220 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,
221 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c,
222 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c,
223 0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74,
224 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72,
225 0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c,
226 0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74,
227 0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65,
228 0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65,
229 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64,
230 0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,
231 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63,
232 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69,
233 0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d,
234 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a,
235 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e
236 };
237
238 private static final String SPDY2_DICT_S =
239 "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" +
240 "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" +
241 "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" +
242 "-agent10010120020120220320420520630030130230330430530630740040140240340440" +
243 "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" +
244 "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" +
245 "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" +
246 "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" +
247 "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" +
248 "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" +
249 "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" +
250 "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" +
251 ".1statusversionurl ";
252 static final byte[] SPDY2_DICT;
253 static {
254 byte[] SPDY2_DICT_ = null;
255
256 try {
257 SPDY2_DICT_ = SPDY2_DICT_S.getBytes("US-ASCII");
258
259 SPDY2_DICT_[SPDY2_DICT_.length - 1] = (byte) 0;
260 } catch (Exception e) {
261 SPDY2_DICT_ = new byte[1];
262 }
263
264 SPDY2_DICT = SPDY2_DICT_;
265 }
266
267
268 private SpdyCodecUtil() {
269 }
270
271
272
273
274
275 static int getUnsignedShort(ChannelBuffer buf, int offset) {
276 return (buf.getByte(offset) & 0xFF) << 8 |
277 buf.getByte(offset + 1) & 0xFF;
278 }
279
280
281
282
283 static int getUnsignedMedium(ChannelBuffer buf, int offset) {
284 return (buf.getByte(offset) & 0xFF) << 16 |
285 (buf.getByte(offset + 1) & 0xFF) << 8 |
286 buf.getByte(offset + 2) & 0xFF;
287 }
288
289
290
291
292 static int getUnsignedInt(ChannelBuffer buf, int offset) {
293 return (buf.getByte(offset) & 0x7F) << 24 |
294 (buf.getByte(offset + 1) & 0xFF) << 16 |
295 (buf.getByte(offset + 2) & 0xFF) << 8 |
296 buf.getByte(offset + 3) & 0xFF;
297 }
298
299
300
301
302 static int getSignedInt(ChannelBuffer buf, int offset) {
303 return (buf.getByte(offset) & 0xFF) << 24 |
304 (buf.getByte(offset + 1) & 0xFF) << 16 |
305 (buf.getByte(offset + 2) & 0xFF) << 8 |
306 buf.getByte(offset + 3) & 0xFF;
307 }
308
309
310
311
312 static boolean isServerId(int id) {
313
314 return id % 2 == 0;
315 }
316
317
318
319
320 static void validateHeaderName(String name) {
321 if (name == null) {
322 throw new NullPointerException("name");
323 }
324 if (name.length() == 0) {
325 throw new IllegalArgumentException(
326 "name cannot be length zero");
327 }
328
329
330 if (name.length() > SPDY_MAX_NV_LENGTH) {
331 throw new IllegalArgumentException(
332 "name exceeds allowable length: " + name);
333 }
334 for (int i = 0; i < name.length(); i ++) {
335 char c = name.charAt(i);
336 if (c == 0) {
337 throw new IllegalArgumentException(
338 "name contains null character: " + name);
339 }
340 if (c > 127) {
341 throw new IllegalArgumentException(
342 "name contains non-ascii character: " + name);
343 }
344 }
345 }
346
347
348
349
350 static void validateHeaderValue(String value) {
351 if (value == null) {
352 throw new NullPointerException("value");
353 }
354 for (int i = 0; i < value.length(); i ++) {
355 char c = value.charAt(i);
356 if (c == 0) {
357 throw new IllegalArgumentException(
358 "value contains null character: " + value);
359 }
360 }
361 }
362 }