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

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

Issue 10832335: WebSocket over SPDY: update test data and expectation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review 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
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.h ('k') | net/spdy/spdy_test_util_spdy3.h » ('j') | 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_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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 extra_header_count, 447 extra_header_count,
448 /*compressed*/ false, 448 /*compressed*/ false,
449 stream_id, 449 stream_id,
450 LOWEST, 450 LOWEST,
451 SYN_STREAM, 451 SYN_STREAM,
452 CONTROL_FLAG_NONE, 452 CONTROL_FLAG_NONE,
453 kConnectHeaders, 453 kConnectHeaders,
454 arraysize(kConnectHeaders)); 454 arraysize(kConnectHeaders));
455 } 455 }
456 456
457 // Constructs a standard SPDY SYN_STREAM frame for a WebSocket over SPDY
458 // opening handshake.
459 SpdyFrame* ConstructSpdyWebSocket(int stream_id,
460 const char* path,
461 const char* host,
462 const char* origin) {
463 const char* const kWebSocketHeaders[] = {
464 "path",
465 path,
466 "host",
467 host,
468 "version",
469 "WebSocket/13",
470 "scheme",
471 "ws",
472 "origin",
473 origin
474 };
475 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
476 /*extra_header_count*/ 0,
477 /*compressed*/ false,
478 stream_id,
479 LOWEST,
480 SYN_STREAM,
481 CONTROL_FLAG_NONE,
482 kWebSocketHeaders,
483 arraysize(kWebSocketHeaders));
484 }
485
486 // Constructs a standard SPDY push SYN packet. 457 // Constructs a standard SPDY push SYN packet.
487 // |extra_headers| are the extra header-value pairs, which typically 458 // |extra_headers| are the extra header-value pairs, which typically
488 // will vary the most between calls. 459 // will vary the most between calls.
489 // Returns a SpdyFrame. 460 // Returns a SpdyFrame.
490 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 461 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
491 int extra_header_count, 462 int extra_header_count,
492 int stream_id, 463 int stream_id,
493 int associated_stream_id) { 464 int associated_stream_id) {
494 const char* const kStandardGetHeaders[] = { 465 const char* const kStandardGetHeaders[] = {
495 "hello", 466 "hello",
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 extra_header_count, 647 extra_header_count,
677 false, 648 false,
678 stream_id, 649 stream_id,
679 LOWEST, 650 LOWEST,
680 SYN_REPLY, 651 SYN_REPLY,
681 CONTROL_FLAG_NONE, 652 CONTROL_FLAG_NONE,
682 kStandardGetHeaders, 653 kStandardGetHeaders,
683 arraysize(kStandardGetHeaders)); 654 arraysize(kStandardGetHeaders));
684 } 655 }
685 656
686 // Constructs a standard SPDY SYN_REPLY packet to match the WebSocket over SPDY
687 // opening handshake.
688 // Returns a SpdyFrame.
689 SpdyFrame* ConstructSpdyWebSocketSynReply(int stream_id) {
690 static const char* const kStandardWebSocketHeaders[] = {
691 "status",
692 "101"
693 };
694 return ConstructSpdyControlFrame(NULL,
695 0,
696 false,
697 stream_id,
698 LOWEST,
699 SYN_REPLY,
700 CONTROL_FLAG_NONE,
701 kStandardWebSocketHeaders,
702 arraysize(kStandardWebSocketHeaders));
703 }
704
705 // Constructs a standard SPDY POST SYN packet. 657 // Constructs a standard SPDY POST SYN packet.
706 // |content_length| is the size of post data. 658 // |content_length| is the size of post data.
707 // |extra_headers| are the extra header-value pairs, which typically 659 // |extra_headers| are the extra header-value pairs, which typically
708 // will vary the most between calls. 660 // will vary the most between calls.
709 // Returns a SpdyFrame. 661 // Returns a SpdyFrame.
710 SpdyFrame* ConstructSpdyPost(int64 content_length, 662 SpdyFrame* ConstructSpdyPost(int64 content_length,
711 const char* const extra_headers[], 663 const char* const extra_headers[],
712 int extra_header_count) { 664 int extra_header_count) {
713 std::string length_str = base::Int64ToString(content_length); 665 std::string length_str = base::Int64ToString(content_length);
714 const char* post_headers[] = { 666 const char* post_headers[] = {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 753 }
802 754
803 // Constructs a single SPDY data frame with the given content. 755 // Constructs a single SPDY data frame with the given content.
804 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, 756 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data,
805 uint32 len, bool fin) { 757 uint32 len, bool fin) {
806 BufferedSpdyFramer framer(2); 758 BufferedSpdyFramer framer(2);
807 return framer.CreateDataFrame( 759 return framer.CreateDataFrame(
808 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); 760 stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
809 } 761 }
810 762
811 // Constructs a SPDY HEADERS frame for a WebSocket frame over SPDY.
812 SpdyFrame* ConstructSpdyWebSocketHeadersFrame(int stream_id,
813 const char* length,
814 bool fin) {
815 static const char* const kHeaders[] = {
816 "opcode",
817 "1", // text frame
818 "length",
819 length,
820 "fin",
821 fin ? "1" : "0"
822 };
823 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
824 /*extra_header_count*/ 0,
825 /*compression*/ false,
826 stream_id,
827 LOWEST,
828 HEADERS,
829 CONTROL_FLAG_NONE,
830 kHeaders,
831 arraysize(kHeaders));
832 }
833
834 // Wraps |frame| in the payload of a data frame in stream |stream_id|. 763 // Wraps |frame| in the payload of a data frame in stream |stream_id|.
835 SpdyFrame* ConstructWrappedSpdyFrame( 764 SpdyFrame* ConstructWrappedSpdyFrame(
836 const scoped_ptr<SpdyFrame>& frame, 765 const scoped_ptr<SpdyFrame>& frame,
837 int stream_id) { 766 int stream_id) {
838 return ConstructSpdyBodyFrame(stream_id, frame->data(), 767 return ConstructSpdyBodyFrame(stream_id, frame->data(),
839 frame->length() + SpdyFrame::kHeaderSize, 768 frame->length() + SpdyFrame::kHeaderSize,
840 false); 769 false);
841 } 770 }
842 771
843 // Construct an expected SPDY reply string. 772 // Construct an expected SPDY reply string.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 } 1021 }
1093 1022
1094 SpdyTestStateHelper::~SpdyTestStateHelper() { 1023 SpdyTestStateHelper::~SpdyTestStateHelper() {
1095 SpdySession::ResetStaticSettingsToInit(); 1024 SpdySession::ResetStaticSettingsToInit();
1096 // TODO(rch): save/restore this value 1025 // TODO(rch): save/restore this value
1097 BufferedSpdyFramer::set_enable_compression_default(true); 1026 BufferedSpdyFramer::set_enable_compression_default(true);
1098 } 1027 }
1099 1028
1100 } // namespace test_spdy2 1029 } // namespace test_spdy2
1101 } // namespace net 1030 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.h ('k') | net/spdy/spdy_test_util_spdy3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698