OLD | NEW |
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 #include "net/spdy/spdy_test_util_spdy2.h" | 5 #include "net/spdy/spdy_test_util_spdy2.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 // Construct a SPDY packet. | 164 // Construct a SPDY packet. |
165 // |head| is the start of the packet, up to but not including | 165 // |head| is the start of the packet, up to but not including |
166 // the header value pairs. | 166 // the header value pairs. |
167 // |extra_headers| are the extra header-value pairs, which typically | 167 // |extra_headers| are the extra header-value pairs, which typically |
168 // will vary the most between calls. | 168 // will vary the most between calls. |
169 // |tail| is any (relatively constant) header-value pairs to add. | 169 // |tail| is any (relatively constant) header-value pairs to add. |
170 // |buffer| is the buffer we're filling in. | 170 // |buffer| is the buffer we're filling in. |
171 // Returns a SpdyFrame. | 171 // Returns a SpdyFrame. |
172 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, | 172 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, |
173 const char* const extra_headers[], | 173 const char* const extra_headers[], |
174 int extra_header_count, | 174 int extra_header_count, |
175 const char* const tail[], | 175 const char* const tail[], |
176 int tail_header_count) { | 176 int tail_header_count) { |
177 BufferedSpdyFramer framer(2); | 177 BufferedSpdyFramer framer(2, header_info.compressed); |
178 SpdyHeaderBlock headers; | 178 SpdyHeaderBlock headers; |
179 // Copy in the extra headers to our map. | 179 // Copy in the extra headers to our map. |
180 AppendHeadersToSpdyFrame(extra_headers, extra_header_count, &headers); | 180 AppendHeadersToSpdyFrame(extra_headers, extra_header_count, &headers); |
181 // Copy in the tail headers to our map. | 181 // Copy in the tail headers to our map. |
182 if (tail && tail_header_count) | 182 if (tail && tail_header_count) |
183 AppendHeadersToSpdyFrame(tail, tail_header_count, &headers); | 183 AppendHeadersToSpdyFrame(tail, tail_header_count, &headers); |
184 SpdyFrame* frame = NULL; | 184 SpdyFrame* frame = NULL; |
185 switch (header_info.kind) { | 185 switch (header_info.kind) { |
186 case SYN_STREAM: | 186 case SYN_STREAM: |
187 frame = framer.CreateSynStream(header_info.id, header_info.assoc_id, | 187 frame = framer.CreateSynStream(header_info.id, header_info.assoc_id, |
(...skipping 18 matching lines...) Expand all Loading... |
206 header_info.data_flags); | 206 header_info.data_flags); |
207 break; | 207 break; |
208 } | 208 } |
209 return frame; | 209 return frame; |
210 } | 210 } |
211 | 211 |
212 // Construct an expected SPDY SETTINGS frame. | 212 // Construct an expected SPDY SETTINGS frame. |
213 // |settings| are the settings to set. | 213 // |settings| are the settings to set. |
214 // Returns the constructed frame. The caller takes ownership of the frame. | 214 // Returns the constructed frame. The caller takes ownership of the frame. |
215 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) { | 215 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) { |
216 BufferedSpdyFramer framer(2); | 216 BufferedSpdyFramer framer(2, false); |
217 return framer.CreateSettings(settings); | 217 return framer.CreateSettings(settings); |
218 } | 218 } |
219 | 219 |
220 // Construct an expected SPDY CREDENTIAL frame. | 220 // Construct an expected SPDY CREDENTIAL frame. |
221 // |credential| is the credential to sen. | 221 // |credential| is the credential to sen. |
222 // Returns the constructed frame. The caller takes ownership of the frame. | 222 // Returns the constructed frame. The caller takes ownership of the frame. |
223 SpdyFrame* ConstructSpdyCredential( | 223 SpdyFrame* ConstructSpdyCredential( |
224 const SpdyCredential& credential) { | 224 const SpdyCredential& credential) { |
225 BufferedSpdyFramer framer(2); | 225 BufferedSpdyFramer framer(2, false); |
226 return framer.CreateCredentialFrame(credential); | 226 return framer.CreateCredentialFrame(credential); |
227 } | 227 } |
228 | 228 |
229 // Construct a SPDY PING frame. | 229 // Construct a SPDY PING frame. |
230 // Returns the constructed frame. The caller takes ownership of the frame. | 230 // Returns the constructed frame. The caller takes ownership of the frame. |
231 SpdyFrame* ConstructSpdyPing(uint32 ping_id) { | 231 SpdyFrame* ConstructSpdyPing(uint32 ping_id) { |
232 BufferedSpdyFramer framer(2); | 232 BufferedSpdyFramer framer(2, false); |
233 return framer.CreatePingFrame(ping_id); | 233 return framer.CreatePingFrame(ping_id); |
234 } | 234 } |
235 | 235 |
236 // Construct a SPDY GOAWAY frame. | 236 // Construct a SPDY GOAWAY frame. |
237 // Returns the constructed frame. The caller takes ownership of the frame. | 237 // Returns the constructed frame. The caller takes ownership of the frame. |
238 SpdyFrame* ConstructSpdyGoAway() { | 238 SpdyFrame* ConstructSpdyGoAway() { |
239 BufferedSpdyFramer framer(2); | 239 BufferedSpdyFramer framer(2, false); |
240 return framer.CreateGoAway(0, GOAWAY_OK); | 240 return framer.CreateGoAway(0, GOAWAY_OK); |
241 } | 241 } |
242 | 242 |
243 // Construct a SPDY WINDOW_UPDATE frame. | 243 // Construct a SPDY WINDOW_UPDATE frame. |
244 // Returns the constructed frame. The caller takes ownership of the frame. | 244 // Returns the constructed frame. The caller takes ownership of the frame. |
245 SpdyFrame* ConstructSpdyWindowUpdate( | 245 SpdyFrame* ConstructSpdyWindowUpdate( |
246 const SpdyStreamId stream_id, uint32 delta_window_size) { | 246 const SpdyStreamId stream_id, uint32 delta_window_size) { |
247 BufferedSpdyFramer framer(2); | 247 BufferedSpdyFramer framer(2, false); |
248 return framer.CreateWindowUpdate(stream_id, delta_window_size); | 248 return framer.CreateWindowUpdate(stream_id, delta_window_size); |
249 } | 249 } |
250 | 250 |
251 // Construct a SPDY RST_STREAM frame. | 251 // Construct a SPDY RST_STREAM frame. |
252 // Returns the constructed frame. The caller takes ownership of the frame. | 252 // Returns the constructed frame. The caller takes ownership of the frame. |
253 SpdyFrame* ConstructSpdyRstStream(SpdyStreamId stream_id, | 253 SpdyFrame* ConstructSpdyRstStream(SpdyStreamId stream_id, |
254 SpdyStatusCodes status) { | 254 SpdyStatusCodes status) { |
255 BufferedSpdyFramer framer(2); | 255 BufferedSpdyFramer framer(2, false); |
256 return framer.CreateRstStream(stream_id, status); | 256 return framer.CreateRstStream(stream_id, status); |
257 } | 257 } |
258 | 258 |
259 // Construct a single SPDY header entry, for validation. | 259 // Construct a single SPDY header entry, for validation. |
260 // |extra_headers| are the extra header-value pairs. | 260 // |extra_headers| are the extra header-value pairs. |
261 // |buffer| is the buffer we're filling in. | 261 // |buffer| is the buffer we're filling in. |
262 // |index| is the index of the header we want. | 262 // |index| is the index of the header we want. |
263 // Returns the number of bytes written into |buffer|. | 263 // Returns the number of bytes written into |buffer|. |
264 int ConstructSpdyHeader(const char* const extra_headers[], | 264 int ConstructSpdyHeader(const char* const extra_headers[], |
265 int extra_header_count, | 265 int extra_header_count, |
(...skipping 24 matching lines...) Expand all Loading... |
290 this_value = ""; | 290 this_value = ""; |
291 int n = base::snprintf(buffer, | 291 int n = base::snprintf(buffer, |
292 buffer_length, | 292 buffer_length, |
293 "%s: %s\r\n", | 293 "%s: %s\r\n", |
294 this_header, | 294 this_header, |
295 this_value); | 295 this_value); |
296 return n; | 296 return n; |
297 } | 297 } |
298 | 298 |
299 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], | 299 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], |
300 int extra_header_count, | 300 int extra_header_count, |
301 bool compressed, | 301 bool compressed, |
302 int stream_id, | 302 int stream_id, |
303 RequestPriority request_priority, | 303 RequestPriority request_priority, |
304 SpdyControlType type, | 304 SpdyControlType type, |
305 SpdyControlFlags flags, | 305 SpdyControlFlags flags, |
306 const char* const* kHeaders, | 306 const char* const* kHeaders, |
307 int kHeadersSize) { | 307 int kHeadersSize) { |
308 return ConstructSpdyControlFrame(extra_headers, | 308 return ConstructSpdyControlFrame(extra_headers, |
309 extra_header_count, | 309 extra_header_count, |
310 compressed, | 310 compressed, |
311 stream_id, | 311 stream_id, |
312 request_priority, | 312 request_priority, |
313 type, | 313 type, |
314 flags, | 314 flags, |
315 kHeaders, | 315 kHeaders, |
316 kHeadersSize, | 316 kHeadersSize, |
317 0); | 317 0); |
318 } | 318 } |
319 | 319 |
320 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], | 320 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], |
321 int extra_header_count, | 321 int extra_header_count, |
322 bool compressed, | 322 bool compressed, |
323 int stream_id, | 323 int stream_id, |
324 RequestPriority request_priority, | 324 RequestPriority request_priority, |
325 SpdyControlType type, | 325 SpdyControlType type, |
326 SpdyControlFlags flags, | 326 SpdyControlFlags flags, |
327 const char* const* kHeaders, | 327 const char* const* kHeaders, |
328 int kHeadersSize, | 328 int kHeadersSize, |
329 int associated_stream_id) { | 329 int associated_stream_id) { |
330 const SpdyHeaderInfo kSynStartHeader = { | 330 const SpdyHeaderInfo kSynStartHeader = { |
331 type, // Kind = Syn | 331 type, // Kind = Syn |
332 stream_id, // Stream ID | 332 stream_id, // Stream ID |
333 associated_stream_id, // Associated stream ID | 333 associated_stream_id, // Associated stream ID |
334 ConvertRequestPriorityToSpdyPriority(request_priority, 2), | 334 ConvertRequestPriorityToSpdyPriority(request_priority, 2), |
335 // Priority | 335 // Priority |
336 flags, // Control Flags | 336 flags, // Control Flags |
337 compressed, // Compressed | 337 compressed, // Compressed |
338 INVALID, // Status | 338 INVALID, // Status |
339 NULL, // Data | 339 NULL, // Data |
340 0, // Length | 340 0, // Length |
341 DATA_FLAG_NONE // Data Flags | 341 DATA_FLAG_NONE // Data Flags |
342 }; | 342 }; |
343 return ConstructSpdyPacket(kSynStartHeader, | 343 return ConstructSpdyPacket(kSynStartHeader, |
344 extra_headers, | 344 extra_headers, |
345 extra_header_count, | 345 extra_header_count, |
346 kHeaders, | 346 kHeaders, |
347 kHeadersSize / 2); | 347 kHeadersSize / 2); |
348 } | 348 } |
349 | 349 |
350 // Constructs a standard SPDY GET SYN packet, optionally compressed | 350 // Constructs a standard SPDY GET SYN packet, optionally compressed |
351 // for the url |url|. | 351 // for the url |url|. |
352 // |extra_headers| are the extra header-value pairs, which typically | 352 // |extra_headers| are the extra header-value pairs, which typically |
353 // will vary the most between calls. | 353 // will vary the most between calls. |
354 // Returns a SpdyFrame. | 354 // Returns a SpdyFrame. |
355 SpdyFrame* ConstructSpdyGet(const char* const url, | 355 SpdyFrame* ConstructSpdyGet(const char* const url, |
356 bool compressed, | 356 bool compressed, |
357 int stream_id, | 357 int stream_id, |
358 RequestPriority request_priority) { | 358 RequestPriority request_priority) { |
359 const SpdyHeaderInfo kSynStartHeader = { | 359 const SpdyHeaderInfo kSynStartHeader = { |
360 SYN_STREAM, // Kind = Syn | 360 SYN_STREAM, // Kind = Syn |
361 stream_id, // Stream ID | 361 stream_id, // Stream ID |
362 0, // Associated stream ID | 362 0, // Associated stream ID |
363 ConvertRequestPriorityToSpdyPriority(request_priority, 2), | 363 ConvertRequestPriorityToSpdyPriority(request_priority, 2), |
364 // Priority | 364 // Priority |
365 CONTROL_FLAG_FIN, // Control Flags | 365 CONTROL_FLAG_FIN, // Control Flags |
366 compressed, // Compressed | 366 compressed, // Compressed |
367 INVALID, // Status | 367 INVALID, // Status |
368 NULL, // Data | 368 NULL, // Data |
369 0, // Length | 369 0, // Length |
370 DATA_FLAG_NONE // Data Flags | 370 DATA_FLAG_NONE // Data Flags |
371 }; | 371 }; |
372 | 372 |
373 std::string scheme, host, path; | 373 std::string scheme, host, path; |
374 ParseUrl(url, &scheme, &host, &path); | 374 ParseUrl(url, &scheme, &host, &path); |
375 const char* const headers[] = { | 375 const char* const headers[] = { |
376 "method", "GET", | 376 "method", "GET", |
377 "url", path.c_str(), | 377 "url", path.c_str(), |
378 "host", host.c_str(), | 378 "host", host.c_str(), |
379 "scheme", scheme.c_str(), | 379 "scheme", scheme.c_str(), |
380 "version", "HTTP/1.1" | 380 "version", "HTTP/1.1" |
381 }; | 381 }; |
382 return ConstructSpdyPacket( | 382 return ConstructSpdyPacket( |
383 kSynStartHeader, | 383 kSynStartHeader, |
384 NULL, | 384 NULL, |
385 0, | 385 0, |
386 headers, | 386 headers, |
387 arraysize(headers) / 2); | 387 arraysize(headers) / 2); |
388 } | 388 } |
389 | 389 |
390 // Constructs a standard SPDY GET SYN packet, optionally compressed. | 390 // Constructs a standard SPDY GET SYN packet, optionally compressed. |
391 // |extra_headers| are the extra header-value pairs, which typically | 391 // |extra_headers| are the extra header-value pairs, which typically |
392 // will vary the most between calls. | 392 // will vary the most between calls. |
393 // Returns a SpdyFrame. | 393 // Returns a SpdyFrame. |
394 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | 394 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], |
395 int extra_header_count, | 395 int extra_header_count, |
396 bool compressed, | 396 bool compressed, |
397 int stream_id, | 397 int stream_id, |
398 RequestPriority request_priority) { | 398 RequestPriority request_priority) { |
399 return ConstructSpdyGet(extra_headers, extra_header_count, compressed, | 399 return ConstructSpdyGet(extra_headers, extra_header_count, compressed, |
400 stream_id, request_priority, true); | 400 stream_id, request_priority, true); |
401 } | 401 } |
402 | 402 |
403 // Constructs a standard SPDY GET SYN packet, optionally compressed. | 403 // Constructs a standard SPDY GET SYN packet, optionally compressed. |
404 // |extra_headers| are the extra header-value pairs, which typically | 404 // |extra_headers| are the extra header-value pairs, which typically |
405 // will vary the most between calls. | 405 // will vary the most between calls. |
406 // Returns a SpdyFrame. | 406 // Returns a SpdyFrame. |
407 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | 407 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], |
408 int extra_header_count, | 408 int extra_header_count, |
409 bool compressed, | 409 bool compressed, |
410 int stream_id, | 410 int stream_id, |
411 RequestPriority request_priority, | 411 RequestPriority request_priority, |
412 bool direct) { | 412 bool direct) { |
413 const char* const kStandardGetHeaders[] = { | 413 const char* const kStandardGetHeaders[] = { |
414 "method", | 414 "method", "GET", |
415 "GET", | 415 "url", (direct ? "/" : "http://www.google.com/"), |
416 "url", | 416 "host", "www.google.com", |
417 (direct ? "/" : "http://www.google.com/"), | 417 "scheme", "http", |
418 "host", | 418 "version", "HTTP/1.1" |
419 "www.google.com", | |
420 "scheme", | |
421 "http", | |
422 "version", | |
423 "HTTP/1.1" | |
424 }; | 419 }; |
425 return ConstructSpdyControlFrame(extra_headers, | 420 return ConstructSpdyControlFrame(extra_headers, |
426 extra_header_count, | 421 extra_header_count, |
427 compressed, | 422 compressed, |
428 stream_id, | 423 stream_id, |
429 request_priority, | 424 request_priority, |
430 SYN_STREAM, | 425 SYN_STREAM, |
431 CONTROL_FLAG_FIN, | 426 CONTROL_FLAG_FIN, |
432 kStandardGetHeaders, | 427 kStandardGetHeaders, |
433 arraysize(kStandardGetHeaders)); | 428 arraysize(kStandardGetHeaders)); |
434 } | 429 } |
435 | 430 |
436 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. | 431 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. |
437 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], | 432 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], |
438 int extra_header_count, | 433 int extra_header_count, |
439 int stream_id) { | 434 int stream_id) { |
440 const char* const kConnectHeaders[] = { | 435 const char* const kConnectHeaders[] = { |
441 "method", "CONNECT", | 436 "method", "CONNECT", |
442 "url", "www.google.com:443", | 437 "url", "www.google.com:443", |
443 "host", "www.google.com", | 438 "host", "www.google.com", |
444 "version", "HTTP/1.1", | 439 "version", "HTTP/1.1", |
445 }; | 440 }; |
446 return ConstructSpdyControlFrame(extra_headers, | 441 return ConstructSpdyControlFrame(extra_headers, |
447 extra_header_count, | 442 extra_header_count, |
448 /*compressed*/ false, | 443 /*compressed*/ false, |
449 stream_id, | 444 stream_id, |
450 LOWEST, | 445 LOWEST, |
451 SYN_STREAM, | 446 SYN_STREAM, |
452 CONTROL_FLAG_NONE, | 447 CONTROL_FLAG_NONE, |
453 kConnectHeaders, | 448 kConnectHeaders, |
454 arraysize(kConnectHeaders)); | 449 arraysize(kConnectHeaders)); |
455 } | 450 } |
456 | 451 |
457 // Constructs a standard SPDY push SYN packet. | 452 // Constructs a standard SPDY push SYN packet. |
458 // |extra_headers| are the extra header-value pairs, which typically | 453 // |extra_headers| are the extra header-value pairs, which typically |
459 // will vary the most between calls. | 454 // will vary the most between calls. |
460 // Returns a SpdyFrame. | 455 // Returns a SpdyFrame. |
461 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], | 456 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], |
462 int extra_header_count, | 457 int extra_header_count, |
463 int stream_id, | 458 int stream_id, |
464 int associated_stream_id) { | 459 int associated_stream_id) { |
465 const char* const kStandardGetHeaders[] = { | 460 const char* const kStandardGetHeaders[] = { |
466 "hello", | 461 "hello", "bye", |
467 "bye", | 462 "status", "200", |
468 "status", | 463 "version", "HTTP/1.1" |
469 "200", | |
470 "version", | |
471 "HTTP/1.1" | |
472 }; | 464 }; |
473 return ConstructSpdyControlFrame(extra_headers, | 465 return ConstructSpdyControlFrame(extra_headers, |
474 extra_header_count, | 466 extra_header_count, |
475 false, | 467 false, |
476 stream_id, | 468 stream_id, |
477 LOWEST, | 469 LOWEST, |
478 SYN_STREAM, | 470 SYN_STREAM, |
479 CONTROL_FLAG_NONE, | 471 CONTROL_FLAG_NONE, |
480 kStandardGetHeaders, | 472 kStandardGetHeaders, |
481 arraysize(kStandardGetHeaders), | 473 arraysize(kStandardGetHeaders), |
482 associated_stream_id); | 474 associated_stream_id); |
483 } | 475 } |
484 | 476 |
485 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], | 477 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], |
486 int extra_header_count, | 478 int extra_header_count, |
487 int stream_id, | 479 int stream_id, |
488 int associated_stream_id, | 480 int associated_stream_id, |
489 const char* url) { | 481 const char* url) { |
490 const char* const kStandardGetHeaders[] = { | 482 const char* const kStandardGetHeaders[] = { |
491 "hello", | 483 "hello", "bye", |
492 "bye", | 484 "status", "200 OK", |
493 "status", | 485 "url", url, |
494 "200 OK", | 486 "version", "HTTP/1.1" |
495 "url", | |
496 url, | |
497 "version", | |
498 "HTTP/1.1" | |
499 }; | 487 }; |
500 return ConstructSpdyControlFrame(extra_headers, | 488 return ConstructSpdyControlFrame(extra_headers, |
501 extra_header_count, | 489 extra_header_count, |
502 false, | 490 false, |
503 stream_id, | 491 stream_id, |
504 LOWEST, | 492 LOWEST, |
505 SYN_STREAM, | 493 SYN_STREAM, |
506 CONTROL_FLAG_NONE, | 494 CONTROL_FLAG_NONE, |
507 kStandardGetHeaders, | 495 kStandardGetHeaders, |
508 arraysize(kStandardGetHeaders), | 496 arraysize(kStandardGetHeaders), |
509 associated_stream_id); | 497 associated_stream_id); |
510 | 498 |
511 } | 499 } |
512 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], | 500 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], |
513 int extra_header_count, | 501 int extra_header_count, |
514 int stream_id, | 502 int stream_id, |
515 int associated_stream_id, | 503 int associated_stream_id, |
516 const char* url, | 504 const char* url, |
517 const char* status, | 505 const char* status, |
518 const char* location) { | 506 const char* location) { |
519 const char* const kStandardGetHeaders[] = { | 507 const char* const kStandardGetHeaders[] = { |
520 "hello", | 508 "hello", "bye", |
521 "bye", | 509 "status", status, |
522 "status", | 510 "location", location, |
523 status, | 511 "url", url, |
524 "location", | 512 "version", "HTTP/1.1" |
525 location, | |
526 "url", | |
527 url, | |
528 "version", | |
529 "HTTP/1.1" | |
530 }; | 513 }; |
531 return ConstructSpdyControlFrame(extra_headers, | 514 return ConstructSpdyControlFrame(extra_headers, |
532 extra_header_count, | 515 extra_header_count, |
533 false, | 516 false, |
534 stream_id, | 517 stream_id, |
535 LOWEST, | 518 LOWEST, |
536 SYN_STREAM, | 519 SYN_STREAM, |
537 CONTROL_FLAG_NONE, | 520 CONTROL_FLAG_NONE, |
538 kStandardGetHeaders, | 521 kStandardGetHeaders, |
539 arraysize(kStandardGetHeaders), | 522 arraysize(kStandardGetHeaders), |
540 associated_stream_id); | 523 associated_stream_id); |
541 } | 524 } |
542 | 525 |
543 SpdyFrame* ConstructSpdyPush(int stream_id, | 526 SpdyFrame* ConstructSpdyPush(int stream_id, |
544 int associated_stream_id, | 527 int associated_stream_id, |
545 const char* url) { | 528 const char* url) { |
546 const char* const kStandardGetHeaders[] = { | 529 const char* const kStandardGetHeaders[] = { |
547 "url", | 530 "url", url |
548 url | |
549 }; | 531 }; |
550 return ConstructSpdyControlFrame(0, | 532 return ConstructSpdyControlFrame(0, |
551 0, | 533 0, |
552 false, | 534 false, |
553 stream_id, | 535 stream_id, |
554 LOWEST, | 536 LOWEST, |
555 SYN_STREAM, | 537 SYN_STREAM, |
556 CONTROL_FLAG_NONE, | 538 CONTROL_FLAG_NONE, |
557 kStandardGetHeaders, | 539 kStandardGetHeaders, |
558 arraysize(kStandardGetHeaders), | 540 arraysize(kStandardGetHeaders), |
559 associated_stream_id); | 541 associated_stream_id); |
560 } | 542 } |
561 | 543 |
562 SpdyFrame* ConstructSpdyPushHeaders(int stream_id, | 544 SpdyFrame* ConstructSpdyPushHeaders(int stream_id, |
563 const char* const extra_headers[], | 545 const char* const extra_headers[], |
564 int extra_header_count) { | 546 int extra_header_count) { |
565 const char* const kStandardGetHeaders[] = { | 547 const char* const kStandardGetHeaders[] = { |
566 "status", | 548 "status", "200 OK", |
567 "200 OK", | 549 "version", "HTTP/1.1" |
568 "version", | |
569 "HTTP/1.1" | |
570 }; | 550 }; |
571 return ConstructSpdyControlFrame(extra_headers, | 551 return ConstructSpdyControlFrame(extra_headers, |
572 extra_header_count, | 552 extra_header_count, |
573 false, | 553 false, |
574 stream_id, | 554 stream_id, |
575 LOWEST, | 555 LOWEST, |
576 HEADERS, | 556 HEADERS, |
577 CONTROL_FLAG_NONE, | 557 CONTROL_FLAG_NONE, |
578 kStandardGetHeaders, | 558 kStandardGetHeaders, |
579 arraysize(kStandardGetHeaders)); | 559 arraysize(kStandardGetHeaders)); |
580 } | 560 } |
581 | 561 |
582 // Constructs a standard SPDY SYN_REPLY packet with the specified status code. | 562 // Constructs a standard SPDY SYN_REPLY packet with the specified status code. |
583 // Returns a SpdyFrame. | 563 // Returns a SpdyFrame. |
584 SpdyFrame* ConstructSpdySynReplyError( | 564 SpdyFrame* ConstructSpdySynReplyError(const char* const status, |
585 const char* const status, | 565 const char* const* const extra_headers, |
586 const char* const* const extra_headers, | 566 int extra_header_count, |
587 int extra_header_count, | 567 int stream_id) { |
588 int stream_id) { | |
589 const char* const kStandardGetHeaders[] = { | 568 const char* const kStandardGetHeaders[] = { |
590 "hello", | 569 "hello", "bye", |
591 "bye", | 570 "status", status, |
592 "status", | 571 "version", "HTTP/1.1" |
593 status, | |
594 "version", | |
595 "HTTP/1.1" | |
596 }; | 572 }; |
597 return ConstructSpdyControlFrame(extra_headers, | 573 return ConstructSpdyControlFrame(extra_headers, |
598 extra_header_count, | 574 extra_header_count, |
599 false, | 575 false, |
600 stream_id, | 576 stream_id, |
601 LOWEST, | 577 LOWEST, |
602 SYN_REPLY, | 578 SYN_REPLY, |
603 CONTROL_FLAG_NONE, | 579 CONTROL_FLAG_NONE, |
604 kStandardGetHeaders, | 580 kStandardGetHeaders, |
605 arraysize(kStandardGetHeaders)); | 581 arraysize(kStandardGetHeaders)); |
606 } | 582 } |
607 | 583 |
608 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. | 584 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. |
609 // |extra_headers| are the extra header-value pairs, which typically | 585 // |extra_headers| are the extra header-value pairs, which typically |
610 // will vary the most between calls. | 586 // will vary the most between calls. |
611 // Returns a SpdyFrame. | 587 // Returns a SpdyFrame. |
612 SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id) { | 588 SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id) { |
613 static const char* const kExtraHeaders[] = { | 589 static const char* const kExtraHeaders[] = { |
614 "location", | 590 "location", "http://www.foo.com/index.php", |
615 "http://www.foo.com/index.php", | |
616 }; | 591 }; |
617 return ConstructSpdySynReplyError("301 Moved Permanently", kExtraHeaders, | 592 return ConstructSpdySynReplyError("301 Moved Permanently", kExtraHeaders, |
618 arraysize(kExtraHeaders)/2, stream_id); | 593 arraysize(kExtraHeaders)/2, stream_id); |
619 } | 594 } |
620 | 595 |
621 // Constructs a standard SPDY SYN_REPLY packet with an Internal Server | 596 // Constructs a standard SPDY SYN_REPLY packet with an Internal Server |
622 // Error status code. | 597 // Error status code. |
623 // Returns a SpdyFrame. | 598 // Returns a SpdyFrame. |
624 SpdyFrame* ConstructSpdySynReplyError(int stream_id) { | 599 SpdyFrame* ConstructSpdySynReplyError(int stream_id) { |
625 return ConstructSpdySynReplyError("500 Internal Server Error", NULL, 0, 1); | 600 return ConstructSpdySynReplyError("500 Internal Server Error", NULL, 0, 1); |
626 } | 601 } |
627 | 602 |
628 | |
629 | |
630 | |
631 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. | 603 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. |
632 // |extra_headers| are the extra header-value pairs, which typically | 604 // |extra_headers| are the extra header-value pairs, which typically |
633 // will vary the most between calls. | 605 // will vary the most between calls. |
634 // Returns a SpdyFrame. | 606 // Returns a SpdyFrame. |
635 SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], | 607 SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], |
636 int extra_header_count, | 608 int extra_header_count, |
637 int stream_id) { | 609 int stream_id) { |
638 static const char* const kStandardGetHeaders[] = { | 610 static const char* const kStandardGetHeaders[] = { |
639 "hello", | 611 "hello", "bye", |
640 "bye", | 612 "status", "200", |
641 "status", | 613 "version", "HTTP/1.1" |
642 "200", | |
643 "version", | |
644 "HTTP/1.1" | |
645 }; | 614 }; |
646 return ConstructSpdyControlFrame(extra_headers, | 615 return ConstructSpdyControlFrame(extra_headers, |
647 extra_header_count, | 616 extra_header_count, |
648 false, | 617 false, |
649 stream_id, | 618 stream_id, |
650 LOWEST, | 619 LOWEST, |
651 SYN_REPLY, | 620 SYN_REPLY, |
652 CONTROL_FLAG_NONE, | 621 CONTROL_FLAG_NONE, |
653 kStandardGetHeaders, | 622 kStandardGetHeaders, |
654 arraysize(kStandardGetHeaders)); | 623 arraysize(kStandardGetHeaders)); |
655 } | 624 } |
656 | 625 |
657 // Constructs a standard SPDY POST SYN packet. | 626 // Constructs a standard SPDY POST SYN packet. |
658 // |content_length| is the size of post data. | 627 // |content_length| is the size of post data. |
659 // |extra_headers| are the extra header-value pairs, which typically | 628 // |extra_headers| are the extra header-value pairs, which typically |
660 // will vary the most between calls. | 629 // will vary the most between calls. |
661 // Returns a SpdyFrame. | 630 // Returns a SpdyFrame. |
662 SpdyFrame* ConstructSpdyPost(int64 content_length, | 631 SpdyFrame* ConstructSpdyPost(int64 content_length, |
663 const char* const extra_headers[], | 632 const char* const extra_headers[], |
664 int extra_header_count) { | 633 int extra_header_count) { |
665 std::string length_str = base::Int64ToString(content_length); | 634 std::string length_str = base::Int64ToString(content_length); |
666 const char* post_headers[] = { | 635 const char* post_headers[] = { |
667 "method", | 636 "method", "POST", |
668 "POST", | 637 "url", "/", |
669 "url", | 638 "host", "www.google.com", |
670 "/", | 639 "scheme", "http", |
671 "host", | 640 "version", "HTTP/1.1", |
672 "www.google.com", | 641 "content-length", length_str.c_str() |
673 "scheme", | |
674 "http", | |
675 "version", | |
676 "HTTP/1.1", | |
677 "content-length", | |
678 length_str.c_str() | |
679 }; | 642 }; |
680 return ConstructSpdyControlFrame(extra_headers, | 643 return ConstructSpdyControlFrame(extra_headers, |
681 extra_header_count, | 644 extra_header_count, |
682 false, | 645 false, |
683 1, | 646 1, |
684 LOWEST, | 647 LOWEST, |
685 SYN_STREAM, | 648 SYN_STREAM, |
686 CONTROL_FLAG_NONE, | 649 CONTROL_FLAG_NONE, |
687 post_headers, | 650 post_headers, |
688 arraysize(post_headers)); | 651 arraysize(post_headers)); |
689 } | 652 } |
690 | 653 |
691 // Constructs a chunked transfer SPDY POST SYN packet. | 654 // Constructs a chunked transfer SPDY POST SYN packet. |
692 // |extra_headers| are the extra header-value pairs, which typically | 655 // |extra_headers| are the extra header-value pairs, which typically |
693 // will vary the most between calls. | 656 // will vary the most between calls. |
694 // Returns a SpdyFrame. | 657 // Returns a SpdyFrame. |
695 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], | 658 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], |
696 int extra_header_count) { | 659 int extra_header_count) { |
697 const char* post_headers[] = { | 660 const char* post_headers[] = { |
698 "method", | 661 "method", "POST", |
699 "POST", | 662 "url", "/", |
700 "url", | 663 "host", "www.google.com", |
701 "/", | 664 "scheme", "http", |
702 "host", | 665 "version", "HTTP/1.1" |
703 "www.google.com", | |
704 "scheme", | |
705 "http", | |
706 "version", | |
707 "HTTP/1.1" | |
708 }; | 666 }; |
709 return ConstructSpdyControlFrame(extra_headers, | 667 return ConstructSpdyControlFrame(extra_headers, |
710 extra_header_count, | 668 extra_header_count, |
711 false, | 669 false, |
712 1, | 670 1, |
713 LOWEST, | 671 LOWEST, |
714 SYN_STREAM, | 672 SYN_STREAM, |
715 CONTROL_FLAG_NONE, | 673 CONTROL_FLAG_NONE, |
716 post_headers, | 674 post_headers, |
717 arraysize(post_headers)); | 675 arraysize(post_headers)); |
718 } | 676 } |
719 | 677 |
720 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. | 678 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. |
721 // |extra_headers| are the extra header-value pairs, which typically | 679 // |extra_headers| are the extra header-value pairs, which typically |
722 // will vary the most between calls. | 680 // will vary the most between calls. |
723 // Returns a SpdyFrame. | 681 // Returns a SpdyFrame. |
724 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], | 682 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], |
725 int extra_header_count) { | 683 int extra_header_count) { |
726 static const char* const kStandardGetHeaders[] = { | 684 static const char* const kStandardGetHeaders[] = { |
727 "hello", | 685 "hello", "bye", |
728 "bye", | 686 "status", "200", |
729 "status", | 687 "url", "/index.php", |
730 "200", | 688 "version", "HTTP/1.1" |
731 "url", | |
732 "/index.php", | |
733 "version", | |
734 "HTTP/1.1" | |
735 }; | 689 }; |
736 return ConstructSpdyControlFrame(extra_headers, | 690 return ConstructSpdyControlFrame(extra_headers, |
737 extra_header_count, | 691 extra_header_count, |
738 false, | 692 false, |
739 1, | 693 1, |
740 LOWEST, | 694 LOWEST, |
741 SYN_REPLY, | 695 SYN_REPLY, |
742 CONTROL_FLAG_NONE, | 696 CONTROL_FLAG_NONE, |
743 kStandardGetHeaders, | 697 kStandardGetHeaders, |
744 arraysize(kStandardGetHeaders)); | 698 arraysize(kStandardGetHeaders)); |
745 } | 699 } |
746 | 700 |
747 // Constructs a single SPDY data frame with the default contents. | 701 // Constructs a single SPDY data frame with the default contents. |
748 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { | 702 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { |
749 BufferedSpdyFramer framer(2); | 703 BufferedSpdyFramer framer(2, false); |
750 return framer.CreateDataFrame( | 704 return framer.CreateDataFrame( |
751 stream_id, kUploadData, kUploadDataSize, | 705 stream_id, kUploadData, kUploadDataSize, |
752 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); | 706 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); |
753 } | 707 } |
754 | 708 |
755 // Constructs a single SPDY data frame with the given content. | 709 // Constructs a single SPDY data frame with the given content. |
756 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, | 710 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, |
757 uint32 len, bool fin) { | 711 uint32 len, bool fin) { |
758 BufferedSpdyFramer framer(2); | 712 BufferedSpdyFramer framer(2, false); |
759 return framer.CreateDataFrame( | 713 return framer.CreateDataFrame( |
760 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); | 714 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); |
761 } | 715 } |
762 | 716 |
763 // Wraps |frame| in the payload of a data frame in stream |stream_id|. | 717 // Wraps |frame| in the payload of a data frame in stream |stream_id|. |
764 SpdyFrame* ConstructWrappedSpdyFrame( | 718 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, |
765 const scoped_ptr<SpdyFrame>& frame, | 719 int stream_id) { |
766 int stream_id) { | |
767 return ConstructSpdyBodyFrame(stream_id, frame->data(), | 720 return ConstructSpdyBodyFrame(stream_id, frame->data(), |
768 frame->length() + SpdyFrame::kHeaderSize, | 721 frame->length() + SpdyFrame::kHeaderSize, |
769 false); | 722 false); |
770 } | 723 } |
771 | 724 |
772 // Construct an expected SPDY reply string. | 725 // Construct an expected SPDY reply string. |
773 // |extra_headers| are the extra header-value pairs, which typically | 726 // |extra_headers| are the extra header-value pairs, which typically |
774 // will vary the most between calls. | 727 // will vary the most between calls. |
775 // |buffer| is the buffer we're filling in. | 728 // |buffer| is the buffer we're filling in. |
776 // Returns the number of bytes written into |buffer|. | 729 // Returns the number of bytes written into |buffer|. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 852 |
900 SpdySessionDependencies::SpdySessionDependencies() | 853 SpdySessionDependencies::SpdySessionDependencies() |
901 : host_resolver(new MockCachingHostResolver), | 854 : host_resolver(new MockCachingHostResolver), |
902 cert_verifier(new MockCertVerifier), | 855 cert_verifier(new MockCertVerifier), |
903 proxy_service(ProxyService::CreateDirect()), | 856 proxy_service(ProxyService::CreateDirect()), |
904 ssl_config_service(new SSLConfigServiceDefaults), | 857 ssl_config_service(new SSLConfigServiceDefaults), |
905 socket_factory(new MockClientSocketFactory), | 858 socket_factory(new MockClientSocketFactory), |
906 deterministic_socket_factory(new DeterministicMockClientSocketFactory), | 859 deterministic_socket_factory(new DeterministicMockClientSocketFactory), |
907 http_auth_handler_factory( | 860 http_auth_handler_factory( |
908 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 861 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
| 862 enable_ip_pooling(true), |
| 863 enable_compression(false), |
| 864 enable_ping(false), |
| 865 time_func(&base::TimeTicks::Now), |
909 net_log(NULL) { | 866 net_log(NULL) { |
910 // Note: The CancelledTransaction test does cleanup by running all | 867 // Note: The CancelledTransaction test does cleanup by running all |
911 // tasks in the message loop (RunAllPending). Unfortunately, that | 868 // tasks in the message loop (RunAllPending). Unfortunately, that |
912 // doesn't clean up tasks on the host resolver thread; and | 869 // doesn't clean up tasks on the host resolver thread; and |
913 // TCPConnectJob is currently not cancellable. Using synchronous | 870 // TCPConnectJob is currently not cancellable. Using synchronous |
914 // lookups allows the test to shutdown cleanly. Until we have | 871 // lookups allows the test to shutdown cleanly. Until we have |
915 // cancellable TCPConnectJobs, use synchronous lookups. | 872 // cancellable TCPConnectJobs, use synchronous lookups. |
916 host_resolver->set_synchronous_mode(true); | 873 host_resolver->set_synchronous_mode(true); |
917 } | 874 } |
918 | 875 |
919 SpdySessionDependencies::SpdySessionDependencies(ProxyService* proxy_service) | 876 SpdySessionDependencies::SpdySessionDependencies(ProxyService* proxy_service) |
920 : host_resolver(new MockHostResolver), | 877 : host_resolver(new MockHostResolver), |
921 cert_verifier(new MockCertVerifier), | 878 cert_verifier(new MockCertVerifier), |
922 proxy_service(proxy_service), | 879 proxy_service(proxy_service), |
923 ssl_config_service(new SSLConfigServiceDefaults), | 880 ssl_config_service(new SSLConfigServiceDefaults), |
924 socket_factory(new MockClientSocketFactory), | 881 socket_factory(new MockClientSocketFactory), |
925 deterministic_socket_factory(new DeterministicMockClientSocketFactory), | 882 deterministic_socket_factory(new DeterministicMockClientSocketFactory), |
926 http_auth_handler_factory( | 883 http_auth_handler_factory( |
927 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 884 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
| 885 enable_ip_pooling(true), |
| 886 enable_compression(false), |
| 887 enable_ping(false), |
| 888 time_func(&base::TimeTicks::Now), |
928 net_log(NULL) {} | 889 net_log(NULL) {} |
929 | 890 |
930 SpdySessionDependencies::~SpdySessionDependencies() {} | 891 SpdySessionDependencies::~SpdySessionDependencies() {} |
931 | 892 |
932 // static | 893 // static |
933 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession( | 894 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession( |
934 SpdySessionDependencies* session_deps) { | 895 SpdySessionDependencies* session_deps) { |
935 net::HttpNetworkSession::Params params = CreateSessionParams(session_deps); | 896 net::HttpNetworkSession::Params params = CreateSessionParams(session_deps); |
936 params.client_socket_factory = session_deps->socket_factory.get(); | 897 params.client_socket_factory = session_deps->socket_factory.get(); |
937 HttpNetworkSession* http_session = new HttpNetworkSession(params); | 898 HttpNetworkSession* http_session = new HttpNetworkSession(params); |
(...skipping 18 matching lines...) Expand all Loading... |
956 net::HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( | 917 net::HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( |
957 SpdySessionDependencies* session_deps) { | 918 SpdySessionDependencies* session_deps) { |
958 net::HttpNetworkSession::Params params; | 919 net::HttpNetworkSession::Params params; |
959 params.host_resolver = session_deps->host_resolver.get(); | 920 params.host_resolver = session_deps->host_resolver.get(); |
960 params.cert_verifier = session_deps->cert_verifier.get(); | 921 params.cert_verifier = session_deps->cert_verifier.get(); |
961 params.proxy_service = session_deps->proxy_service.get(); | 922 params.proxy_service = session_deps->proxy_service.get(); |
962 params.ssl_config_service = session_deps->ssl_config_service; | 923 params.ssl_config_service = session_deps->ssl_config_service; |
963 params.http_auth_handler_factory = | 924 params.http_auth_handler_factory = |
964 session_deps->http_auth_handler_factory.get(); | 925 session_deps->http_auth_handler_factory.get(); |
965 params.http_server_properties = &session_deps->http_server_properties; | 926 params.http_server_properties = &session_deps->http_server_properties; |
| 927 params.enable_spdy_ip_pooling = session_deps->enable_ip_pooling; |
| 928 params.enable_spdy_compression = session_deps->enable_compression; |
| 929 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; |
| 930 params.spdy_default_protocol = kProtoSPDY2; |
| 931 params.time_func = session_deps->time_func; |
966 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; | 932 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; |
967 params.net_log = session_deps->net_log; | 933 params.net_log = session_deps->net_log; |
968 return params; | 934 return params; |
969 } | 935 } |
970 | 936 |
971 SpdyURLRequestContext::SpdyURLRequestContext() | 937 SpdyURLRequestContext::SpdyURLRequestContext() |
972 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { | 938 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { |
973 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); | 939 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); |
974 storage_.set_cert_verifier(new MockCertVerifier); | 940 storage_.set_cert_verifier(new MockCertVerifier); |
975 storage_.set_proxy_service(ProxyService::CreateDirect()); | 941 storage_.set_proxy_service(ProxyService::CreateDirect()); |
976 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 942 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
977 storage_.set_http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault( | 943 storage_.set_http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault( |
978 host_resolver())); | 944 host_resolver())); |
979 storage_.set_http_server_properties(new HttpServerPropertiesImpl); | 945 storage_.set_http_server_properties(new HttpServerPropertiesImpl); |
980 net::HttpNetworkSession::Params params; | 946 net::HttpNetworkSession::Params params; |
981 params.client_socket_factory = &socket_factory_; | 947 params.client_socket_factory = &socket_factory_; |
982 params.host_resolver = host_resolver(); | 948 params.host_resolver = host_resolver(); |
983 params.cert_verifier = cert_verifier(); | 949 params.cert_verifier = cert_verifier(); |
984 params.proxy_service = proxy_service(); | 950 params.proxy_service = proxy_service(); |
985 params.ssl_config_service = ssl_config_service(); | 951 params.ssl_config_service = ssl_config_service(); |
986 params.http_auth_handler_factory = http_auth_handler_factory(); | 952 params.http_auth_handler_factory = http_auth_handler_factory(); |
987 params.network_delegate = network_delegate(); | 953 params.network_delegate = network_delegate(); |
| 954 params.enable_spdy_compression = false; |
| 955 params.enable_spdy_ping_based_connection_checking = false; |
| 956 params.spdy_default_protocol = kProtoSPDY2; |
988 params.http_server_properties = http_server_properties(); | 957 params.http_server_properties = http_server_properties(); |
989 scoped_refptr<HttpNetworkSession> network_session( | 958 scoped_refptr<HttpNetworkSession> network_session( |
990 new HttpNetworkSession(params)); | 959 new HttpNetworkSession(params)); |
991 SpdySessionPoolPeer pool_peer(network_session->spdy_session_pool()); | 960 SpdySessionPoolPeer pool_peer(network_session->spdy_session_pool()); |
992 pool_peer.EnableSendingInitialSettings(false); | 961 pool_peer.EnableSendingInitialSettings(false); |
993 storage_.set_http_transaction_factory(new HttpCache( | 962 storage_.set_http_transaction_factory(new HttpCache( |
994 network_session, | 963 network_session, |
995 HttpCache::DefaultBackend::InMemory(0))); | 964 HttpCache::DefaultBackend::InMemory(0))); |
996 } | 965 } |
997 | 966 |
998 SpdyURLRequestContext::~SpdyURLRequestContext() { | 967 SpdyURLRequestContext::~SpdyURLRequestContext() { |
999 } | 968 } |
1000 | 969 |
1001 const SpdyHeaderInfo MakeSpdyHeader(SpdyControlType type) { | 970 const SpdyHeaderInfo MakeSpdyHeader(SpdyControlType type) { |
1002 const SpdyHeaderInfo kHeader = { | 971 const SpdyHeaderInfo kHeader = { |
1003 type, // Kind = Syn | 972 type, // Kind = Syn |
1004 1, // Stream ID | 973 1, // Stream ID |
1005 0, // Associated stream ID | 974 0, // Associated stream ID |
1006 ConvertRequestPriorityToSpdyPriority(LOWEST, 2), // Priority | 975 ConvertRequestPriorityToSpdyPriority(LOWEST, 2), // Priority |
1007 CONTROL_FLAG_FIN, // Control Flags | 976 CONTROL_FLAG_FIN, // Control Flags |
1008 false, // Compressed | 977 false, // Compressed |
1009 INVALID, // Status | 978 INVALID, // Status |
1010 NULL, // Data | 979 NULL, // Data |
1011 0, // Length | 980 0, // Length |
1012 DATA_FLAG_NONE // Data Flags | 981 DATA_FLAG_NONE // Data Flags |
1013 }; | 982 }; |
1014 return kHeader; | 983 return kHeader; |
1015 } | 984 } |
1016 | 985 |
1017 SpdyTestStateHelper::SpdyTestStateHelper() { | |
1018 // Pings can be non-deterministic, because they are sent via timer. | |
1019 SpdySession::set_enable_ping_based_connection_checking(false); | |
1020 // Compression is per-session which makes it impossible to create | |
1021 // SPDY frames with static methods. | |
1022 BufferedSpdyFramer::set_enable_compression_default(false); | |
1023 } | |
1024 | |
1025 SpdyTestStateHelper::~SpdyTestStateHelper() { | |
1026 SpdySession::ResetStaticSettingsToInit(); | |
1027 // TODO(rch): save/restore this value | |
1028 BufferedSpdyFramer::set_enable_compression_default(true); | |
1029 } | |
1030 | |
1031 } // namespace test_spdy2 | 986 } // namespace test_spdy2 |
1032 } // namespace net | 987 } // namespace net |
OLD | NEW |