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

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

Issue 1402373005: Remove description from HTTP/2 RST_STREAM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.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_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 2426
2427 { 2427 {
2428 const char kDescription[] = "RST_STREAM frame"; 2428 const char kDescription[] = "RST_STREAM frame";
2429 const unsigned char kV3FrameData[] = { // Also applies for V2. 2429 const unsigned char kV3FrameData[] = { // Also applies for V2.
2430 0x80, spdy_version_ch_, 0x00, 0x03, 2430 0x80, spdy_version_ch_, 0x00, 0x03,
2431 0x00, 0x00, 0x00, 0x08, 2431 0x00, 0x00, 0x00, 0x08,
2432 0x00, 0x00, 0x00, 0x01, 2432 0x00, 0x00, 0x00, 0x01,
2433 0x00, 0x00, 0x00, 0x01, 2433 0x00, 0x00, 0x00, 0x01,
2434 }; 2434 };
2435 const unsigned char kH2FrameData[] = { 2435 const unsigned char kH2FrameData[] = {
2436 0x00, 0x00, 0x07, 0x03, 2436 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00,
2437 0x00, 0x00, 0x00, 0x00, 2437 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
2438 0x01, 0x00, 0x00, 0x00,
2439 0x01, 0x52, 0x53, 0x54
2440 }; 2438 };
2441 SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); 2439 SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR);
2442 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); 2440 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream));
2443 if (IsHttp2()) { 2441 if (IsHttp2()) {
2444 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); 2442 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData));
2445 } else { 2443 } else {
2446 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2444 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2447 } 2445 }
2448 } 2446 }
2449 2447
2450 { 2448 {
2451 const char kDescription[] = "RST_STREAM frame with max stream ID"; 2449 const char kDescription[] = "RST_STREAM frame with max stream ID";
2452 const unsigned char kV3FrameData[] = { // Also applies for V2. 2450 const unsigned char kV3FrameData[] = { // Also applies for V2.
2453 0x80, spdy_version_ch_, 0x00, 0x03, 2451 0x80, spdy_version_ch_, 0x00, 0x03,
2454 0x00, 0x00, 0x00, 0x08, 2452 0x00, 0x00, 0x00, 0x08,
2455 0x7f, 0xff, 0xff, 0xff, 2453 0x7f, 0xff, 0xff, 0xff,
2456 0x00, 0x00, 0x00, 0x01, 2454 0x00, 0x00, 0x00, 0x01,
2457 }; 2455 };
2458 const unsigned char kH2FrameData[] = { 2456 const unsigned char kH2FrameData[] = {
2459 0x00, 0x00, 0x04, 0x03, 2457 0x00, 0x00, 0x04, 0x03,
2460 0x00, 0x7f, 0xff, 0xff, 2458 0x00, 0x7f, 0xff, 0xff,
2461 0xff, 0x00, 0x00, 0x00, 2459 0xff, 0x00, 0x00, 0x00,
2462 0x01, 2460 0x01,
2463 }; 2461 };
2464 SpdyRstStreamIR rst_stream(0x7FFFFFFF, 2462 SpdyRstStreamIR rst_stream(0x7FFFFFFF, RST_STREAM_PROTOCOL_ERROR);
2465 RST_STREAM_PROTOCOL_ERROR,
2466 "");
2467 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); 2463 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream));
2468 if (IsHttp2()) { 2464 if (IsHttp2()) {
2469 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); 2465 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData));
2470 } else { 2466 } else {
2471 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2467 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2472 } 2468 }
2473 } 2469 }
2474 2470
2475 { 2471 {
2476 const char kDescription[] = "RST_STREAM frame with max status code"; 2472 const char kDescription[] = "RST_STREAM frame with max status code";
2477 const unsigned char kV3FrameData[] = { // Also applies for V2. 2473 const unsigned char kV3FrameData[] = { // Also applies for V2.
2478 0x80, spdy_version_ch_, 0x00, 0x03, 2474 0x80, spdy_version_ch_, 0x00, 0x03,
2479 0x00, 0x00, 0x00, 0x08, 2475 0x00, 0x00, 0x00, 0x08,
2480 0x7f, 0xff, 0xff, 0xff, 2476 0x7f, 0xff, 0xff, 0xff,
2481 0x00, 0x00, 0x00, 0x06, 2477 0x00, 0x00, 0x00, 0x06,
2482 }; 2478 };
2483 const unsigned char kH2FrameData[] = { 2479 const unsigned char kH2FrameData[] = {
2484 0x00, 0x00, 0x04, 0x03, 2480 0x00, 0x00, 0x04, 0x03,
2485 0x00, 0x7f, 0xff, 0xff, 2481 0x00, 0x7f, 0xff, 0xff,
2486 0xff, 0x00, 0x00, 0x00, 2482 0xff, 0x00, 0x00, 0x00,
2487 0x02, 2483 0x02,
2488 }; 2484 };
2489 SpdyRstStreamIR rst_stream(0x7FFFFFFF, 2485 SpdyRstStreamIR rst_stream(0x7FFFFFFF, RST_STREAM_INTERNAL_ERROR);
2490 RST_STREAM_INTERNAL_ERROR,
2491 "");
2492 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); 2486 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream));
2493 if (IsHttp2()) { 2487 if (IsHttp2()) {
2494 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); 2488 CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData));
2495 } else { 2489 } else {
2496 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2490 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2497 } 2491 }
2498 } 2492 }
2499 } 2493 }
2500 2494
2501 TEST_P(SpdyFramerTest, CreateSettings) { 2495 TEST_P(SpdyFramerTest, CreateSettings) {
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after
5135 5129
5136 TEST_P(SpdyFramerTest, RstStreamFrameFlags) { 5130 TEST_P(SpdyFramerTest, RstStreamFrameFlags) {
5137 uint8 flags = 0; 5131 uint8 flags = 0;
5138 do { 5132 do {
5139 SCOPED_TRACE(testing::Message() << "Flags " << flags); 5133 SCOPED_TRACE(testing::Message() << "Flags " << flags);
5140 5134
5141 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; 5135 testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
5142 SpdyFramer framer(spdy_version_); 5136 SpdyFramer framer(spdy_version_);
5143 framer.set_visitor(&visitor); 5137 framer.set_visitor(&visitor);
5144 5138
5145 SpdyRstStreamIR rst_stream(13, RST_STREAM_CANCEL, ""); 5139 SpdyRstStreamIR rst_stream(13, RST_STREAM_CANCEL);
5146 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); 5140 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream));
5147 SetFrameFlags(frame.get(), flags, spdy_version_); 5141 SetFrameFlags(frame.get(), flags, spdy_version_);
5148 5142
5149 if (flags != 0) { 5143 if (flags != 0) {
5150 EXPECT_CALL(visitor, OnError(_)); 5144 EXPECT_CALL(visitor, OnError(_));
5151 } else { 5145 } else {
5152 EXPECT_CALL(visitor, OnRstStream(13, RST_STREAM_CANCEL)); 5146 EXPECT_CALL(visitor, OnRstStream(13, RST_STREAM_CANCEL));
5153 } 5147 }
5154 5148
5155 framer.ProcessInput(frame->data(), frame->size()); 5149 framer.ProcessInput(frame->data(), frame->size());
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
6119 6113
6120 EXPECT_EQ(1, visitor->data_frame_count_); 6114 EXPECT_EQ(1, visitor->data_frame_count_);
6121 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_)); 6115 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_));
6122 EXPECT_EQ(0, visitor->headers_frame_count_); 6116 EXPECT_EQ(0, visitor->headers_frame_count_);
6123 } 6117 }
6124 } 6118 }
6125 6119
6126 } // namespace test 6120 } // namespace test
6127 6121
6128 } // namespace net 6122 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698