Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: net/spdy/spdy_protocol.h

Issue 9618002: SPDY - integration of spdy/3 code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains some protocol structures for use with Spdy. 5 // This file contains some protocol structures for use with Spdy.
6 6
7 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ 7 #ifndef NET_SPDY_SPDY_PROTOCOL_H_
8 #define NET_SPDY_SPDY_PROTOCOL_H_ 8 #define NET_SPDY_SPDY_PROTOCOL_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // +-----------------+ | 134 // +-----------------+ |
135 // | Proof Length (32 bits) | 135 // | Proof Length (32 bits) |
136 // +----------------------------------+ 136 // +----------------------------------+
137 // | Proof | 137 // | Proof |
138 // +----------------------------------+ <+ 138 // +----------------------------------+ <+
139 // | Certificate Length (32 bits) | | 139 // | Certificate Length (32 bits) | |
140 // +----------------------------------+ | Repeated until end of frame 140 // +----------------------------------+ | Repeated until end of frame
141 // | Certificate | | 141 // | Certificate | |
142 // +----------------------------------+ <+ 142 // +----------------------------------+ <+
143 // 143 //
144
144 namespace spdy { 145 namespace spdy {
145 146
146 // This implementation of Spdy is version 2; It's like version 1, with some
147 // minor tweaks.
148 const int kSpdyProtocolVersion = 2;
149
150 // Initial window size for a Spdy stream 147 // Initial window size for a Spdy stream
151 const size_t kSpdyStreamInitialWindowSize = 64 * 1024; // 64 KBytes 148 const int32 kSpdyStreamInitialWindowSize = 64 * 1024; // 64 KBytes
152 149
153 // Maximum window size for a Spdy stream 150 // Maximum window size for a Spdy stream
154 const size_t kSpdyStreamMaximumWindowSize = 0x7FFFFFFF; // Max signed 32bit int 151 const int32 kSpdyStreamMaximumWindowSize = 0x7FFFFFFF; // Max signed 32bit int
155 152
156 // HTTP-over-SPDY header constants 153 // HTTP-over-SPDY header constants
157 const char kMethod[] = "method"; 154 const char kMethod[] = "method";
158 const char kStatus[] = "status"; 155 const char kStatus[] = "status";
159 const char kUrl[] = "url"; 156 const char kUrl[] = "url";
160 const char kVersion[] = "version"; 157 const char kVersion[] = "version";
161 // When we server push, we will add [path: fully/qualified/url] to the server 158 // When we server push, we will add [path: fully/qualified/url] to the server
162 // push headers so that the client will know what url the data corresponds to. 159 // push headers so that the client will know what url the data corresponds to.
163 const char kPath[] = "path"; 160 const char kPath[] = "path";
164 161
162 // SPDY 2 dictionary.
163 // This is just a hacked dictionary to use for shrinking HTTP-like headers.
164 const char kV2Dictionary[] =
165 "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-"
166 "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi"
167 "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser"
168 "-agent10010120020120220320420520630030130230330430530630740040140240340440"
169 "5406407408409410411412413414415416417500501502503504505accept-rangesageeta"
170 "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic"
171 "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran"
172 "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati"
173 "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo"
174 "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe"
175 "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic"
176 "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1"
177 ".1statusversionurl";
178 const int kV2DictionarySize = arraysize(kV2Dictionary);
179
180 // SPDY 3 dictionary.
181 const char kV3Dictionary[] = {
182 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69, // ....opti
183 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68, // ons....h
184 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70, // ead....p
185 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70, // ost....p
186 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65, // ut....de
187 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05, // lete....
188 0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00, // trace...
189 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, // .accept.
190 0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, // ...accep
191 0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, // t-charse
192 0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, // t....acc
193 0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, // ept-enco
194 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f, // ding....
195 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c, // accept-l
196 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00, // anguage.
197 0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70, // ...accep
198 0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, // t-ranges
199 0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00, // ....age.
200 0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77, // ...allow
201 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68, // ....auth
202 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, // orizatio
203 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63, // n....cac
204 0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, // he-contr
205 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f, // ol....co
206 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, // nnection
207 0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, // ....cont
208 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, // ent-base
209 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74, // ....cont
210 0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, // ent-enco
211 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, // ding....
212 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, // content-
213 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, // language
214 0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74, // ....cont
215 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67, // ent-leng
216 0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, // th....co
217 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, // ntent-lo
218 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, // cation..
219 0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, // ..conten
220 0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00, // t-md5...
221 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, // .content
222 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, // -range..
223 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, // ..conten
224 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00, // t-type..
225 0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, // ..date..
226 0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00, // ..etag..
227 0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, // ..expect
228 0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69, // ....expi
229 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66, // res....f
230 0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68, // rom....h
231 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69, // ost....i
232 0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, // f-match.
233 0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f, // ...if-mo
234 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73, // dified-s
235 0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d, // ince....
236 0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d, // if-none-
237 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00, // match...
238 0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67, // .if-rang
239 0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d, // e....if-
240 0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, // unmodifi
241 0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65, // ed-since
242 0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74, // ....last
243 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, // -modifie
244 0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63, // d....loc
245 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, // ation...
246 0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72, // .max-for
247 0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00, // wards...
248 0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00, // .pragma.
249 0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79, // ...proxy
250 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, // -authent
251 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, // icate...
252 0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61, // .proxy-a
253 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, // uthoriza
254 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, // tion....
255 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00, // range...
256 0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, // .referer
257 0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72, // ....retr
258 0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00, // y-after.
259 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, // ...serve
260 0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00, // r....te.
261 0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, // ...trail
262 0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72, // er....tr
263 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65, // ansfer-e
264 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, // ncoding.
265 0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, // ...upgra
266 0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, // de....us
267 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, // er-agent
268 0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79, // ....vary
269 0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00, // ....via.
270 0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69, // ...warni
271 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77, // ng....ww
272 0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, // w-authen
273 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, // ticate..
274 0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, // ..method
275 0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00, // ....get.
276 0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, // ...statu
277 0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30, // s....200
278 0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76, // .OK....v
279 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, // ersion..
280 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, // ..HTTP.1
281 0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, // .1....ur
282 0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62, // l....pub
283 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73, // lic....s
284 0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69, // et-cooki
285 0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65, // e....kee
286 0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00, // p-alive.
287 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, // ...origi
288 0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32, // n1001012
289 0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, // 01202205
290 0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30, // 20630030
291 0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33, // 23033043
292 0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37, // 05306307
293 0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30, // 40240540
294 0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34, // 64074084
295 0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31, // 09410411
296 0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31, // 41241341
297 0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34, // 44154164
298 0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34, // 17502504
299 0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e, // 505203.N
300 0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f, // on-Autho
301 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, // ritative
302 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, // .Informa
303 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20, // tion204.
304 0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, // No.Conte
305 0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f, // nt301.Mo
306 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d, // ved.Perm
307 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34, // anently4
308 0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52, // 00.Bad.R
309 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30, // equest40
310 0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, // 1.Unauth
311 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30, // orized40
312 0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64, // 3.Forbid
313 0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e, // den404.N
314 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, // ot.Found
315 0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65, // 500.Inte
316 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72, // rnal.Ser
317 0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f, // ver.Erro
318 0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74, // r501.Not
319 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, // .Impleme
320 0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20, // nted503.
321 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, // Service.
322 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, // Unavaila
323 0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46, // bleJan.F
324 0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41, // eb.Mar.A
325 0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a, // pr.May.J
326 0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41, // un.Jul.A
327 0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20, // ug.Sept.
328 0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20, // Oct.Nov.
329 0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30, // Dec.00.0
330 0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e, // 0.00.Mon
331 0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57, // ..Tue..W
332 0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c, // ed..Thu.
333 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61, // .Fri..Sa
334 0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20, // t..Sun..
335 0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b, // GMTchunk
336 0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, // ed.text.
337 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61, // html.ima
338 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69, // ge.png.i
339 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67, // mage.jpg
340 0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, // .image.g
341 0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, // if.appli
342 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, // cation.x
343 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, // ml.appli
344 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, // cation.x
345 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c, // html.xml
346 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, // .text.pl
347 0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74, // ain.text
348 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, // .javascr
349 0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c, // ipt.publ
350 0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, // icprivat
351 0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65, // emax-age
352 0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65, // .gzip.de
353 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, // flate.sd
354 0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, // chcharse
355 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63, // t.utf-8c
356 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69, // harset.i
357 0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d, // so-8859-
358 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a, // 1.utf-..
359 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e // .enq.0.
360 };
361 const int kV3DictionarySize = arraysize(kV3Dictionary);
362
165 // Note: all protocol data structures are on-the-wire format. That means that 363 // Note: all protocol data structures are on-the-wire format. That means that
166 // data is stored in network-normalized order. Readers must use the 364 // data is stored in network-normalized order. Readers must use the
167 // accessors provided or call ntohX() functions. 365 // accessors provided or call ntohX() functions.
168 366
169 // Types of Spdy Control Frames. 367 // Types of Spdy Control Frames.
170 enum SpdyControlType { 368 enum SpdyControlType {
171 SYN_STREAM = 1, 369 SYN_STREAM = 1,
172 SYN_REPLY, 370 SYN_REPLY,
173 RST_STREAM, 371 RST_STREAM,
174 SETTINGS, 372 SETTINGS,
175 NOOP, 373 NOOP, // Because it is valid in SPDY/2, kept for identifiability/enum order.
176 PING, 374 PING,
177 GOAWAY, 375 GOAWAY,
178 HEADERS, 376 HEADERS,
179 WINDOW_UPDATE, 377 WINDOW_UPDATE,
180 CREDENTIAL, 378 CREDENTIAL,
181 NUM_CONTROL_FRAME_TYPES 379 NUM_CONTROL_FRAME_TYPES
182 }; 380 };
183 381
184 // Flags on data packets. 382 // Flags on data packets.
185 enum SpdyDataFlags { 383 enum SpdyDataFlags {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 CANCEL = 5, 430 CANCEL = 5,
233 INTERNAL_ERROR = 6, 431 INTERNAL_ERROR = 6,
234 FLOW_CONTROL_ERROR = 7, 432 FLOW_CONTROL_ERROR = 7,
235 INVALID_ASSOCIATED_STREAM = 8, 433 INVALID_ASSOCIATED_STREAM = 8,
236 NUM_STATUS_CODES = 9 434 NUM_STATUS_CODES = 9
237 }; 435 };
238 436
239 // A SPDY stream id is a 31 bit entity. 437 // A SPDY stream id is a 31 bit entity.
240 typedef uint32 SpdyStreamId; 438 typedef uint32 SpdyStreamId;
241 439
242 // A SPDY priority is a number between 0 and 3 (inclusive). 440 // A SPDY priority is a number between 0 and 7 (inclusive).
441 // SPDY priority range is version-dependant. For SPDY 2 and below, priority is a
442 // number between 0 and 3.
243 typedef uint8 SpdyPriority; 443 typedef uint8 SpdyPriority;
244 444
245 // SPDY Priorities. (there are only 2 bits) 445 // SPDY Priorities. (there are only 2 bits)
246 #define SPDY_PRIORITY_LOWEST 3 446 #define SPDY_PRIORITY_LOWEST 3
247 #define SPDY_PRIORITY_HIGHEST 0 447 #define SPDY_PRIORITY_HIGHEST 0
248 448
249 // ------------------------------------------------------------------------- 449 // -------------------------------------------------------------------------
250 // These structures mirror the protocol structure definitions. 450 // These structures mirror the protocol structure definitions.
251 451
252 // For the control data structures, we pack so that sizes match the 452 // For the control data structures, we pack so that sizes match the
(...skipping 25 matching lines...) Expand all
278 struct SpdySynStreamControlFrameBlock : SpdyFrameBlock { 478 struct SpdySynStreamControlFrameBlock : SpdyFrameBlock {
279 SpdyStreamId stream_id_; 479 SpdyStreamId stream_id_;
280 SpdyStreamId associated_stream_id_; 480 SpdyStreamId associated_stream_id_;
281 SpdyPriority priority_; 481 SpdyPriority priority_;
282 uint8 unused_; 482 uint8 unused_;
283 }; 483 };
284 484
285 // A SYN_REPLY Control Frame structure. 485 // A SYN_REPLY Control Frame structure.
286 struct SpdySynReplyControlFrameBlock : SpdyFrameBlock { 486 struct SpdySynReplyControlFrameBlock : SpdyFrameBlock {
287 SpdyStreamId stream_id_; 487 SpdyStreamId stream_id_;
288 uint16 unused_;
289 }; 488 };
290 489
291 // A RST_STREAM Control Frame structure. 490 // A RST_STREAM Control Frame structure.
292 struct SpdyRstStreamControlFrameBlock : SpdyFrameBlock { 491 struct SpdyRstStreamControlFrameBlock : SpdyFrameBlock {
293 SpdyStreamId stream_id_; 492 SpdyStreamId stream_id_;
294 uint32 status_; 493 uint32 status_;
295 }; 494 };
296 495
297 // A SETTINGS Control Frame structure. 496 // A SETTINGS Control Frame structure.
298 struct SpdySettingsControlFrameBlock : SpdyFrameBlock { 497 struct SpdySettingsControlFrameBlock : SpdyFrameBlock {
299 uint32 num_entries_; 498 uint32 num_entries_;
300 // Variable data here. 499 // Variable data here.
301 }; 500 };
302 501
303 // A NOOP Control Frame structure.
304 struct SpdyNoopControlFrameBlock : SpdyFrameBlock {
305 };
306
307 // A PING Control Frame structure. 502 // A PING Control Frame structure.
308 struct SpdyPingControlFrameBlock : SpdyFrameBlock { 503 struct SpdyPingControlFrameBlock : SpdyFrameBlock {
309 uint32 unique_id_; 504 uint32 unique_id_;
310 }; 505 };
311 506
507 // TODO(avd): remove this struct
312 // A CREDENTIAL Control Frame structure. 508 // A CREDENTIAL Control Frame structure.
313 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock { 509 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock {
314 uint16 slot_; 510 uint16 slot_;
315 uint32 proof_len_; 511 uint32 proof_len_;
316 // Variable data here. 512 // Variable data here.
317 // proof data 513 // proof data
318 // for each certificate: unit32 certificate_len + certificate_data[i] 514 // for each certificate: unit32 certificate_len + certificate_data[i]
319 }; 515 };
320 516
321 // A GOAWAY Control Frame structure. 517 // A GOAWAY Control Frame structure.
322 struct SpdyGoAwayControlFrameBlock : SpdyFrameBlock { 518 struct SpdyGoAwayControlFrameBlock : SpdyFrameBlock {
323 SpdyStreamId last_accepted_stream_id_; 519 SpdyStreamId last_accepted_stream_id_;
324 }; 520 };
325 521
326 // A HEADERS Control Frame structure. 522 // A HEADERS Control Frame structure.
327 struct SpdyHeadersControlFrameBlock : SpdyFrameBlock { 523 struct SpdyHeadersControlFrameBlock : SpdyFrameBlock {
328 SpdyStreamId stream_id_; 524 SpdyStreamId stream_id_;
329 uint16 unused_;
330 }; 525 };
331 526
332 // A WINDOW_UPDATE Control Frame structure 527 // A WINDOW_UPDATE Control Frame structure
333 struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock { 528 struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock {
334 SpdyStreamId stream_id_; 529 SpdyStreamId stream_id_;
335 uint32 delta_window_size_; 530 uint32 delta_window_size_;
336 }; 531 };
337 532
338 // A structure for the 8 bit flags and 24 bit ID fields.
339 union SettingsFlagsAndId {
340 // Sets both flags and id to the value for flags-and-id as sent over the wire
341 SettingsFlagsAndId(uint32 val) : id_(val) {}
342 uint8 flags() const { return flags_[0]; }
343 void set_flags(uint8 flags) { flags_[0] = flags; }
344 uint32 id() const { return (ntohl(id_) & kSettingsIdMask); }
345 void set_id(uint32 id) {
346 DCHECK_EQ(0u, (id & ~kSettingsIdMask));
347 id_ = htonl((flags() << 24) | (id & kSettingsIdMask));
348 }
349
350 uint8 flags_[4]; // 8 bits
351 uint32 id_; // 24 bits
352 };
353
354 #pragma pack(pop) 533 #pragma pack(pop)
355 534
356 // ------------------------------------------------------------------------- 535 // -------------------------------------------------------------------------
357 // Wrapper classes for various SPDY frames. 536 // Wrapper classes for various SPDY frames.
358 537
359 // All Spdy Frame types derive from this SpdyFrame class. 538 // All Spdy Frame types derive from this SpdyFrame class.
360 class SpdyFrame { 539 class SpdyFrame {
361 public: 540 public:
362 // Create a SpdyFrame for a given sized buffer. 541 // Create a SpdyFrame for a given sized buffer.
363 explicit SpdyFrame(size_t size) : frame_(NULL), owns_buffer_(true) { 542 explicit SpdyFrame(size_t size) : frame_(NULL), owns_buffer_(true) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 public: 639 public:
461 explicit SpdyControlFrame(size_t size) : SpdyFrame(size) {} 640 explicit SpdyControlFrame(size_t size) : SpdyFrame(size) {}
462 SpdyControlFrame(char* data, bool owns_buffer) 641 SpdyControlFrame(char* data, bool owns_buffer)
463 : SpdyFrame(data, owns_buffer) {} 642 : SpdyFrame(data, owns_buffer) {}
464 643
465 // Callers can use this method to check if the frame appears to be a valid 644 // Callers can use this method to check if the frame appears to be a valid
466 // frame. Does not guarantee that there are no errors. 645 // frame. Does not guarantee that there are no errors.
467 bool AppearsToBeAValidControlFrame() const { 646 bool AppearsToBeAValidControlFrame() const {
468 // Right now we only check if the frame has an out-of-bounds type. 647 // Right now we only check if the frame has an out-of-bounds type.
469 uint16 type = ntohs(block()->control_.type_); 648 uint16 type = ntohs(block()->control_.type_);
470 return (type >= SYN_STREAM && type < NUM_CONTROL_FRAME_TYPES); 649 // NOOP is not a 'valid' control frame in SPDY/3 and beyond.
650 return type >= SYN_STREAM &&
651 type < NUM_CONTROL_FRAME_TYPES &&
652 (version() == 2 || type != NOOP);
471 } 653 }
472 654
473 uint16 version() const { 655 uint16 version() const {
474 const int kVersionMask = 0x7fff; 656 const int kVersionMask = 0x7fff;
475 return ntohs(block()->control_.version_) & kVersionMask; 657 return ntohs(block()->control_.version_) & kVersionMask;
476 } 658 }
477 659
478 void set_version(uint16 version) { 660 void set_version(uint16 version) {
479 DCHECK_EQ(0u, version & kControlFlagMask); 661 const uint16 kControlBit = 0x80;
480 mutable_block()->control_.version_ = htons(kControlFlagMask | version); 662 DCHECK_EQ(0, version & kControlBit);
663 mutable_block()->control_.version_ = kControlBit | htons(version);
481 } 664 }
482 665
483 SpdyControlType type() const { 666 SpdyControlType type() const {
484 uint16 type = ntohs(block()->control_.type_); 667 uint16 type = ntohs(block()->control_.type_);
485 DCHECK(type >= SYN_STREAM && type < NUM_CONTROL_FRAME_TYPES); 668 LOG_IF(DFATAL, type < SYN_STREAM || type >= NUM_CONTROL_FRAME_TYPES)
669 << "Invalid control frame type " << type;
486 return static_cast<SpdyControlType>(type); 670 return static_cast<SpdyControlType>(type);
487 } 671 }
488 672
489 void set_type(SpdyControlType type) { 673 void set_type(SpdyControlType type) {
490 DCHECK(type >= SYN_STREAM && type < NUM_CONTROL_FRAME_TYPES); 674 DCHECK(type >= SYN_STREAM && type < NUM_CONTROL_FRAME_TYPES);
491 mutable_block()->control_.type_ = htons(type); 675 mutable_block()->control_.type_ = htons(type);
492 } 676 }
493 677
494 // Returns true if this control frame is of a type that has a header block, 678 // Returns true if this control frame is of a type that has a header block,
495 // otherwise it returns false. 679 // otherwise it returns false.
496 bool has_header_block() const { 680 bool has_header_block() const {
497 return type() == SYN_STREAM || type() == SYN_REPLY || type() == HEADERS; 681 return type() == SYN_STREAM || type() == SYN_REPLY || type() == HEADERS;
498 } 682 }
499 683
500 // The size of the 'Number of Name/Value pairs' field in a Name/Value block.
501 static const size_t kNumNameValuePairsSize = 2;
502
503 // The size of the 'Length of a name' field in a Name/Value block.
504 static const size_t kLengthOfNameSize = 2;
505
506 // The size of the 'Length of a value' field in a Name/Value block.
507 static const size_t kLengthOfValueSize = 2;
508
509 private: 684 private:
510 const struct SpdyFrameBlock* block() const { 685 const struct SpdyFrameBlock* block() const {
511 return frame_; 686 return frame_;
512 } 687 }
513 struct SpdyFrameBlock* mutable_block() { 688 struct SpdyFrameBlock* mutable_block() {
514 return frame_; 689 return frame_;
515 } 690 }
516 DISALLOW_COPY_AND_ASSIGN(SpdyControlFrame); 691 DISALLOW_COPY_AND_ASSIGN(SpdyControlFrame);
517 }; 692 };
518 693
(...skipping 14 matching lines...) Expand all
533 708
534 SpdyStreamId associated_stream_id() const { 709 SpdyStreamId associated_stream_id() const {
535 return ntohl(block()->associated_stream_id_) & kStreamIdMask; 710 return ntohl(block()->associated_stream_id_) & kStreamIdMask;
536 } 711 }
537 712
538 void set_associated_stream_id(SpdyStreamId id) { 713 void set_associated_stream_id(SpdyStreamId id) {
539 mutable_block()->associated_stream_id_ = htonl(id & kStreamIdMask); 714 mutable_block()->associated_stream_id_ = htonl(id & kStreamIdMask);
540 } 715 }
541 716
542 SpdyPriority priority() const { 717 SpdyPriority priority() const {
543 return (block()->priority_ & kPriorityMask) >> 6; 718 if (version() < 3) {
719 return (block()->priority_ & kSpdy2PriorityMask) >> 6;
720 } else {
721 return (block()->priority_ & kSpdy3PriorityMask) >> 5;
722 }
544 } 723 }
545 724
546 // The number of bytes in the header block beyond the frame header length. 725 // The number of bytes in the header block beyond the frame header length.
547 int header_block_len() const { 726 int header_block_len() const {
548 return length() - (size() - SpdyFrame::kHeaderSize); 727 return length() - (size() - SpdyFrame::kHeaderSize);
549 } 728 }
550 729
551 const char* header_block() const { 730 const char* header_block() const {
552 return reinterpret_cast<const char*>(block()) + size(); 731 return reinterpret_cast<const char*>(block()) + size();
553 } 732 }
(...skipping 21 matching lines...) Expand all
575 754
576 SpdyStreamId stream_id() const { 755 SpdyStreamId stream_id() const {
577 return ntohl(block()->stream_id_) & kStreamIdMask; 756 return ntohl(block()->stream_id_) & kStreamIdMask;
578 } 757 }
579 758
580 void set_stream_id(SpdyStreamId id) { 759 void set_stream_id(SpdyStreamId id) {
581 mutable_block()->stream_id_ = htonl(id & kStreamIdMask); 760 mutable_block()->stream_id_ = htonl(id & kStreamIdMask);
582 } 761 }
583 762
584 int header_block_len() const { 763 int header_block_len() const {
585 return length() - (size() - SpdyFrame::kHeaderSize); 764 size_t header_block_len = length() - (size() - SpdyFrame::kHeaderSize);
765 // SPDY 2 had 2 bytes of unused space preceeding the header block.
766 if (version() < 3) {
767 header_block_len -= 2;
768 }
769 return header_block_len;
586 } 770 }
587 771
588 const char* header_block() const { 772 const char* header_block() const {
589 return reinterpret_cast<const char*>(block()) + size(); 773 const char* header_block = reinterpret_cast<const char*>(block()) + size();
774 // SPDY 2 had 2 bytes of unused space preceeding the header block.
775 if (version() < 3) {
776 header_block += 2;
777 }
778 return header_block;
590 } 779 }
591 780
592 // Returns the size of the SpdySynReplyControlFrameBlock structure. 781 // Returns the size of the SpdySynReplyControlFrameBlock structure.
593 // Note: this is not the size of the SpdySynReplyControlFrame class. 782 // Note: this is not the size of the SpdySynReplyControlFrame class.
594 static size_t size() { return sizeof(SpdySynReplyControlFrameBlock); } 783 static size_t size() { return sizeof(SpdySynReplyControlFrameBlock); }
595 784
596 private: 785 private:
597 const struct SpdySynReplyControlFrameBlock* block() const { 786 const struct SpdySynReplyControlFrameBlock* block() const {
598 return static_cast<SpdySynReplyControlFrameBlock*>(frame_); 787 return static_cast<SpdySynReplyControlFrameBlock*>(frame_);
599 } 788 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 private: 862 private:
674 const struct SpdySettingsControlFrameBlock* block() const { 863 const struct SpdySettingsControlFrameBlock* block() const {
675 return static_cast<SpdySettingsControlFrameBlock*>(frame_); 864 return static_cast<SpdySettingsControlFrameBlock*>(frame_);
676 } 865 }
677 struct SpdySettingsControlFrameBlock* mutable_block() { 866 struct SpdySettingsControlFrameBlock* mutable_block() {
678 return static_cast<SpdySettingsControlFrameBlock*>(frame_); 867 return static_cast<SpdySettingsControlFrameBlock*>(frame_);
679 } 868 }
680 DISALLOW_COPY_AND_ASSIGN(SpdySettingsControlFrame); 869 DISALLOW_COPY_AND_ASSIGN(SpdySettingsControlFrame);
681 }; 870 };
682 871
683 class SpdyNoOpControlFrame : public SpdyControlFrame {
684 public:
685 SpdyNoOpControlFrame() : SpdyControlFrame(size()) {}
686 SpdyNoOpControlFrame(char* data, bool owns_buffer)
687 : SpdyControlFrame(data, owns_buffer) {}
688
689 static size_t size() { return sizeof(SpdyNoopControlFrameBlock); }
690 };
691
692 class SpdyPingControlFrame : public SpdyControlFrame { 872 class SpdyPingControlFrame : public SpdyControlFrame {
693 public: 873 public:
694 SpdyPingControlFrame() : SpdyControlFrame(size()) {} 874 SpdyPingControlFrame() : SpdyControlFrame(size()) {}
695 SpdyPingControlFrame(char* data, bool owns_buffer) 875 SpdyPingControlFrame(char* data, bool owns_buffer)
696 : SpdyControlFrame(data, owns_buffer) {} 876 : SpdyControlFrame(data, owns_buffer) {}
697 877
698 uint32 unique_id() const { 878 uint32 unique_id() const {
699 return ntohl(block()->unique_id_); 879 return ntohl(block()->unique_id_);
700 } 880 }
701 881
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 SpdyStreamId stream_id() const { 949 SpdyStreamId stream_id() const {
770 return ntohl(block()->stream_id_) & kStreamIdMask; 950 return ntohl(block()->stream_id_) & kStreamIdMask;
771 } 951 }
772 952
773 void set_stream_id(SpdyStreamId id) { 953 void set_stream_id(SpdyStreamId id) {
774 mutable_block()->stream_id_ = htonl(id & kStreamIdMask); 954 mutable_block()->stream_id_ = htonl(id & kStreamIdMask);
775 } 955 }
776 956
777 // The number of bytes in the header block beyond the frame header length. 957 // The number of bytes in the header block beyond the frame header length.
778 int header_block_len() const { 958 int header_block_len() const {
779 return length() - (size() - SpdyFrame::kHeaderSize); 959 size_t header_block_len = length() - (size() - SpdyFrame::kHeaderSize);
960 // SPDY 2 had 2 bytes of unused space preceeding the header block.
961 if (version() < 3) {
962 header_block_len -= 2;
963 }
964 return header_block_len;
780 } 965 }
781 966
782 const char* header_block() const { 967 const char* header_block() const {
783 return reinterpret_cast<const char*>(block()) + size(); 968 const char* header_block = reinterpret_cast<const char*>(block()) + size();
969 // SPDY 2 had 2 bytes of unused space preceeding the header block.
970 if (version() < 3) {
971 header_block += 2;
972 }
973 return header_block;
784 } 974 }
785 975
786 // Returns the size of the SpdyHeadersControlFrameBlock structure. 976 // Returns the size of the SpdyHeadersControlFrameBlock structure.
787 // Note: this is not the size of the SpdyHeadersControlFrame class. 977 // Note: this is not the size of the SpdyHeadersControlFrame class.
788 static size_t size() { return sizeof(SpdyHeadersControlFrameBlock); } 978 static size_t size() { return sizeof(SpdyHeadersControlFrameBlock); }
789 979
790 private: 980 private:
791 const struct SpdyHeadersControlFrameBlock* block() const { 981 const struct SpdyHeadersControlFrameBlock* block() const {
792 return static_cast<SpdyHeadersControlFrameBlock*>(frame_); 982 return static_cast<SpdyHeadersControlFrameBlock*>(frame_);
793 } 983 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 struct SpdyWindowUpdateControlFrameBlock* mutable_block() { 1021 struct SpdyWindowUpdateControlFrameBlock* mutable_block() {
832 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_); 1022 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_);
833 } 1023 }
834 1024
835 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame); 1025 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame);
836 }; 1026 };
837 1027
838 } // namespace spdy 1028 } // namespace spdy
839 1029
840 #endif // NET_SPDY_SPDY_PROTOCOL_H_ 1030 #endif // NET_SPDY_SPDY_PROTOCOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698