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

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

Issue 10810069: SPDY: Add WriteHeaders interface to SpdySession and SpdyStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: spdy3 Created 8 years, 4 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 #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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 extra_header_count, 451 extra_header_count,
452 /*compressed*/ false, 452 /*compressed*/ false,
453 stream_id, 453 stream_id,
454 LOWEST, 454 LOWEST,
455 SYN_STREAM, 455 SYN_STREAM,
456 CONTROL_FLAG_NONE, 456 CONTROL_FLAG_NONE,
457 kConnectHeaders, 457 kConnectHeaders,
458 arraysize(kConnectHeaders)); 458 arraysize(kConnectHeaders));
459 } 459 }
460 460
461 // Constructs a standard SPDY SYN_STREAM frame for a WebSocket over SPDY
462 // opening handshake.
463 SpdyFrame* ConstructSpdyWebSocket(int stream_id,
464 const char* path,
465 const char* host,
466 const char* origin) {
467 const char* const kWebSocketHeaders[] = {
468 ":path",
469 path,
470 ":host",
471 host,
472 ":version",
473 "WebSocket/13",
474 ":scheme",
475 "ws",
476 ":origin",
477 origin
478 };
479 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
480 /*extra_header_count*/ 0,
481 /*compressed*/ false,
482 stream_id,
483 LOWEST,
484 SYN_STREAM,
485 CONTROL_FLAG_NONE,
486 kWebSocketHeaders,
487 arraysize(kWebSocketHeaders));
488 }
489
461 // Constructs a standard SPDY push SYN packet. 490 // Constructs a standard SPDY push SYN packet.
462 // |extra_headers| are the extra header-value pairs, which typically 491 // |extra_headers| are the extra header-value pairs, which typically
463 // will vary the most between calls. 492 // will vary the most between calls.
464 // Returns a SpdyFrame. 493 // Returns a SpdyFrame.
465 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 494 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
466 int extra_header_count, 495 int extra_header_count,
467 int stream_id, 496 int stream_id,
468 int associated_stream_id) { 497 int associated_stream_id) {
469 const char* const kStandardPushHeaders[] = { 498 const char* const kStandardPushHeaders[] = {
470 "hello", "bye", 499 "hello", "bye",
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 extra_header_count, 657 extra_header_count,
629 false, 658 false,
630 stream_id, 659 stream_id,
631 LOWEST, 660 LOWEST,
632 SYN_REPLY, 661 SYN_REPLY,
633 CONTROL_FLAG_NONE, 662 CONTROL_FLAG_NONE,
634 kStandardGetHeaders, 663 kStandardGetHeaders,
635 arraysize(kStandardGetHeaders)); 664 arraysize(kStandardGetHeaders));
636 } 665 }
637 666
667 // Constructs a standard SPDY SYN_REPLY packet to match the WebSocket over SPDY
668 // opening handshake.
669 // Returns a SpdyFrame.
670 SpdyFrame* ConstructSpdyWebSocketSynReply(int stream_id) {
671 static const char* const kStandardWebSocketHeaders[] = {
672 ":status",
673 "101"
674 };
675 return ConstructSpdyControlFrame(NULL,
676 0,
677 false,
678 stream_id,
679 LOWEST,
680 SYN_REPLY,
681 CONTROL_FLAG_NONE,
682 kStandardWebSocketHeaders,
683 arraysize(kStandardWebSocketHeaders));
684 }
685
638 // Constructs a standard SPDY POST SYN packet. 686 // Constructs a standard SPDY POST SYN packet.
639 // |content_length| is the size of post data. 687 // |content_length| is the size of post data.
640 // |extra_headers| are the extra header-value pairs, which typically 688 // |extra_headers| are the extra header-value pairs, which typically
641 // will vary the most between calls. 689 // will vary the most between calls.
642 // Returns a SpdyFrame. 690 // Returns a SpdyFrame.
643 SpdyFrame* ConstructSpdyPost(int64 content_length, 691 SpdyFrame* ConstructSpdyPost(int64 content_length,
644 const char* const extra_headers[], 692 const char* const extra_headers[],
645 int extra_header_count) { 693 int extra_header_count) {
646 std::string length_str = base::Int64ToString(content_length); 694 std::string length_str = base::Int64ToString(content_length);
647 const char* post_headers[] = { 695 const char* post_headers[] = {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 782 }
735 783
736 // Constructs a single SPDY data frame with the given content. 784 // Constructs a single SPDY data frame with the given content.
737 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, 785 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data,
738 uint32 len, bool fin) { 786 uint32 len, bool fin) {
739 BufferedSpdyFramer framer(3); 787 BufferedSpdyFramer framer(3);
740 return framer.CreateDataFrame( 788 return framer.CreateDataFrame(
741 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); 789 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
742 } 790 }
743 791
792 // Constructs a SPDY HEADERS frame for a WebSocket frame over SPDY.
793 SpdyFrame* ConstructSpdyWebSocketHeadersFrame(int stream_id,
794 const char* length,
795 bool fin) {
796 static const char* const kHeaders[] = {
797 ":opcode",
798 "1", // text frame
799 ":length",
800 length,
801 ":fin",
802 fin ? "1" : "0"
803 };
804 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
805 /*extra_header_count*/ 0,
806 /*compression*/ false,
807 stream_id,
808 LOWEST,
809 HEADERS,
810 CONTROL_FLAG_NONE,
811 kHeaders,
812 arraysize(kHeaders));
813 }
814
744 // Wraps |frame| in the payload of a data frame in stream |stream_id|. 815 // Wraps |frame| in the payload of a data frame in stream |stream_id|.
745 SpdyFrame* ConstructWrappedSpdyFrame( 816 SpdyFrame* ConstructWrappedSpdyFrame(
746 const scoped_ptr<SpdyFrame>& frame, 817 const scoped_ptr<SpdyFrame>& frame,
747 int stream_id) { 818 int stream_id) {
748 return ConstructSpdyBodyFrame(stream_id, frame->data(), 819 return ConstructSpdyBodyFrame(stream_id, frame->data(),
749 frame->length() + SpdyFrame::kHeaderSize, 820 frame->length() + SpdyFrame::kHeaderSize,
750 false); 821 false);
751 } 822 }
752 823
753 // Construct an expected SPDY reply string. 824 // Construct an expected SPDY reply string.
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1081
1011 SpdyTestStateHelper::~SpdyTestStateHelper() { 1082 SpdyTestStateHelper::~SpdyTestStateHelper() {
1012 SpdySession::ResetStaticSettingsToInit(); 1083 SpdySession::ResetStaticSettingsToInit();
1013 // TODO(rch): save/restore this value 1084 // TODO(rch): save/restore this value
1014 BufferedSpdyFramer::set_enable_compression_default(true); 1085 BufferedSpdyFramer::set_enable_compression_default(true);
1015 } 1086 }
1016 1087
1017 } // namespace test_spdy3 1088 } // namespace test_spdy3
1018 1089
1019 } // namespace net 1090 } // namespace net
OLDNEW
« net/spdy/spdy_test_util_spdy2.h ('K') | « net/spdy/spdy_test_util_spdy3.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698