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

Side by Side Diff: net/spdy/spdy_test_util_spdy3.cc

Issue 9705046: Switch CreateSpdyHeadersFromHttpRequest to construct the correct headers based on the spdy protocol… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix raman's comments. 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
« no previous file with comments | « net/spdy/spdy_stream_spdy3_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "net/spdy/spdy_test_util_spdy3.h" 5 #include "net/spdy/spdy_test_util_spdy3.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 scoped_array<char> scheme(new char[str_scheme.size() + 1]); 366 scoped_array<char> scheme(new char[str_scheme.size() + 1]);
367 scoped_array<char> host(new char[str_host.size() + 1]); 367 scoped_array<char> host(new char[str_host.size() + 1]);
368 memcpy(req.get(), str_path.c_str(), str_path.size()); 368 memcpy(req.get(), str_path.c_str(), str_path.size());
369 memcpy(scheme.get(), str_scheme.c_str(), str_scheme.size()); 369 memcpy(scheme.get(), str_scheme.c_str(), str_scheme.size());
370 memcpy(host.get(), str_host.c_str(), str_host.size()); 370 memcpy(host.get(), str_host.c_str(), str_host.size());
371 req.get()[str_path.size()] = '\0'; 371 req.get()[str_path.size()] = '\0';
372 scheme.get()[str_scheme.size()] = '\0'; 372 scheme.get()[str_scheme.size()] = '\0';
373 host.get()[str_host.size()] = '\0'; 373 host.get()[str_host.size()] = '\0';
374 374
375 const char* const headers[] = { 375 const char* const headers[] = {
376 "method", 376 ":method",
377 "GET", 377 "GET",
378 "url", 378 ":path",
379 req.get(), 379 req.get(),
380 "host", 380 ":host",
381 host.get(), 381 host.get(),
382 "scheme", 382 ":scheme",
383 scheme.get(), 383 scheme.get(),
384 "version", 384 ":version",
385 "HTTP/1.1" 385 "HTTP/1.1"
386 }; 386 };
387 return ConstructSpdyPacket( 387 return ConstructSpdyPacket(
388 kSynStartHeader, 388 kSynStartHeader,
389 NULL, 389 NULL,
390 0, 390 0,
391 headers, 391 headers,
392 arraysize(headers) / 2); 392 arraysize(headers) / 2);
393 } 393 }
394 394
(...skipping 14 matching lines...) Expand all
409 // |extra_headers| are the extra header-value pairs, which typically 409 // |extra_headers| are the extra header-value pairs, which typically
410 // will vary the most between calls. 410 // will vary the most between calls.
411 // Returns a SpdyFrame. 411 // Returns a SpdyFrame.
412 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 412 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[],
413 int extra_header_count, 413 int extra_header_count,
414 bool compressed, 414 bool compressed,
415 int stream_id, 415 int stream_id,
416 RequestPriority request_priority, 416 RequestPriority request_priority,
417 bool direct) { 417 bool direct) {
418 const char* const kStandardGetHeaders[] = { 418 const char* const kStandardGetHeaders[] = {
419 "method", 419 ":method",
420 "GET", 420 "GET",
421 "url", 421 ":host",
422 (direct ? "/" : "http://www.google.com/"),
423 "host",
424 "www.google.com", 422 "www.google.com",
425 "scheme", 423 ":scheme",
426 "http", 424 "http",
427 "version", 425 ":version",
428 "HTTP/1.1" 426 "HTTP/1.1",
427 ":path",
428 (direct ? "/" : "/")
429 }; 429 };
430 return ConstructSpdyControlFrame(extra_headers, 430 return ConstructSpdyControlFrame(extra_headers,
431 extra_header_count, 431 extra_header_count,
432 compressed, 432 compressed,
433 stream_id, 433 stream_id,
434 request_priority, 434 request_priority,
435 spdy::SYN_STREAM, 435 spdy::SYN_STREAM,
436 spdy::CONTROL_FLAG_FIN, 436 spdy::CONTROL_FLAG_FIN,
437 kStandardGetHeaders, 437 kStandardGetHeaders,
438 arraysize(kStandardGetHeaders)); 438 arraysize(kStandardGetHeaders));
439 } 439 }
440 440
441 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. 441 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request.
442 spdy::SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], 442 spdy::SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[],
443 int extra_header_count, 443 int extra_header_count,
444 int stream_id) { 444 int stream_id) {
445 const char* const kConnectHeaders[] = { 445 const char* const kConnectHeaders[] = {
446 "method", "CONNECT", 446 ":method", "CONNECT",
447 "url", "www.google.com:443", 447 ":path", "www.google.com:443",
448 "host", "www.google.com", 448 ":host", "www.google.com",
449 "version", "HTTP/1.1", 449 ":version", "HTTP/1.1",
450 }; 450 };
451 return ConstructSpdyControlFrame(extra_headers, 451 return ConstructSpdyControlFrame(extra_headers,
452 extra_header_count, 452 extra_header_count,
453 /*compressed*/ false, 453 /*compressed*/ false,
454 stream_id, 454 stream_id,
455 LOWEST, 455 LOWEST,
456 spdy::SYN_STREAM, 456 spdy::SYN_STREAM,
457 spdy::CONTROL_FLAG_NONE, 457 spdy::CONTROL_FLAG_NONE,
458 kConnectHeaders, 458 kConnectHeaders,
459 arraysize(kConnectHeaders)); 459 arraysize(kConnectHeaders));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // Constructs a standard SPDY POST SYN packet. 662 // Constructs a standard SPDY POST SYN packet.
663 // |content_length| is the size of post data. 663 // |content_length| is the size of post data.
664 // |extra_headers| are the extra header-value pairs, which typically 664 // |extra_headers| are the extra header-value pairs, which typically
665 // will vary the most between calls. 665 // will vary the most between calls.
666 // Returns a SpdyFrame. 666 // Returns a SpdyFrame.
667 spdy::SpdyFrame* ConstructSpdyPost(int64 content_length, 667 spdy::SpdyFrame* ConstructSpdyPost(int64 content_length,
668 const char* const extra_headers[], 668 const char* const extra_headers[],
669 int extra_header_count) { 669 int extra_header_count) {
670 std::string length_str = base::Int64ToString(content_length); 670 std::string length_str = base::Int64ToString(content_length);
671 const char* post_headers[] = { 671 const char* post_headers[] = {
672 "method", 672 ":method",
673 "POST", 673 "POST",
674 "url", 674 ":path",
675 "/", 675 "/",
676 "host", 676 ":host",
677 "www.google.com", 677 "www.google.com",
678 "scheme", 678 ":scheme",
679 "http", 679 "http",
680 "version", 680 ":version",
681 "HTTP/1.1", 681 "HTTP/1.1",
682 "content-length", 682 "content-length",
683 length_str.c_str() 683 length_str.c_str()
684 }; 684 };
685 return ConstructSpdyControlFrame(extra_headers, 685 return ConstructSpdyControlFrame(extra_headers,
686 extra_header_count, 686 extra_header_count,
687 false, 687 false,
688 1, 688 1,
689 LOWEST, 689 LOWEST,
690 spdy::SYN_STREAM, 690 spdy::SYN_STREAM,
691 spdy::CONTROL_FLAG_NONE, 691 spdy::CONTROL_FLAG_NONE,
692 post_headers, 692 post_headers,
693 arraysize(post_headers)); 693 arraysize(post_headers));
694 } 694 }
695 695
696 // Constructs a chunked transfer SPDY POST SYN packet. 696 // Constructs a chunked transfer SPDY POST SYN packet.
697 // |extra_headers| are the extra header-value pairs, which typically 697 // |extra_headers| are the extra header-value pairs, which typically
698 // will vary the most between calls. 698 // will vary the most between calls.
699 // Returns a SpdyFrame. 699 // Returns a SpdyFrame.
700 spdy::SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], 700 spdy::SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[],
701 int extra_header_count) { 701 int extra_header_count) {
702 const char* post_headers[] = { 702 const char* post_headers[] = {
703 "method", 703 ":method",
704 "POST", 704 "POST",
705 "url", 705 ":path",
706 "/", 706 "/",
707 "host", 707 ":host",
708 "www.google.com", 708 "www.google.com",
709 "scheme", 709 ":scheme",
710 "http", 710 "http",
711 "version", 711 ":version",
712 "HTTP/1.1" 712 "HTTP/1.1"
713 }; 713 };
714 return ConstructSpdyControlFrame(extra_headers, 714 return ConstructSpdyControlFrame(extra_headers,
715 extra_header_count, 715 extra_header_count,
716 false, 716 false,
717 1, 717 1,
718 LOWEST, 718 LOWEST,
719 spdy::SYN_STREAM, 719 spdy::SYN_STREAM,
720 spdy::CONTROL_FLAG_NONE, 720 spdy::CONTROL_FLAG_NONE,
721 post_headers, 721 post_headers,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 NULL, // Data 1003 NULL, // Data
1004 0, // Length 1004 0, // Length
1005 spdy::DATA_FLAG_NONE // Data Flags 1005 spdy::DATA_FLAG_NONE // Data Flags
1006 }; 1006 };
1007 return kHeader; 1007 return kHeader;
1008 } 1008 }
1009 1009
1010 } // namespace test_spdy3 1010 } // namespace test_spdy3
1011 1011
1012 } // namespace net 1012 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream_spdy3_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698