| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/flip_server/spdy_interface.h" | 5 #include "net/tools/flip_server/spdy_interface.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); | 389 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); |
| 390 DataFrame* df = *i++; | 390 DataFrame* df = *i++; |
| 391 spdy_framer_->ProcessInput(df->data, df->size); | 391 spdy_framer_->ProcessInput(df->data, df->size); |
| 392 checkpoint.Call(0); | 392 checkpoint.Call(0); |
| 393 df = *i++; | 393 df = *i++; |
| 394 spdy_framer_->ProcessInput(df->data, df->size); | 394 spdy_framer_->ProcessInput(df->data, df->size); |
| 395 | 395 |
| 396 ASSERT_EQ(2, spdy_framer_->frames_received()); | 396 ASSERT_EQ(2, spdy_framer_->frames_received()); |
| 397 ASSERT_EQ(2u, actual_header_block.size()); | 397 ASSERT_EQ(2u, actual_header_block.size()); |
| 398 ASSERT_EQ("404 Not Found", actual_header_block[":status"]); | 398 ASSERT_EQ("404 Not Found", |
| 399 ASSERT_EQ("HTTP/1.1", actual_header_block[":version"]); | 399 static_cast<StringPiece>(actual_header_block[":status"])); |
| 400 ASSERT_EQ("HTTP/1.1", |
| 401 static_cast<StringPiece>(actual_header_block[":version"])); |
| 400 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); | 402 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); |
| 401 } | 403 } |
| 402 | 404 |
| 403 TEST_P(SpdySMProxyTest, SendSynStream) { | 405 TEST_P(SpdySMProxyTest, SendSynStream) { |
| 404 uint32 stream_id = 82; | 406 uint32 stream_id = 82; |
| 405 BalsaHeaders headers; | 407 BalsaHeaders headers; |
| 406 SpdyHeaderBlock actual_header_block; | 408 SpdyHeaderBlock actual_header_block; |
| 407 headers.AppendHeader("key1", "value1"); | 409 headers.AppendHeader("key1", "value1"); |
| 408 headers.AppendHeader("Host", "www.example.com"); | 410 headers.AppendHeader("Host", "www.example.com"); |
| 409 headers.SetRequestFirstlineFromStringPieces("GET", "/path", "HTTP/1.1"); | 411 headers.SetRequestFirstlineFromStringPieces("GET", "/path", "HTTP/1.1"); |
| 410 | 412 |
| 411 interface_->SendSynStream(stream_id, headers); | 413 interface_->SendSynStream(stream_id, headers); |
| 412 | 414 |
| 413 ASSERT_EQ(1u, connection_->output_list()->size()); | 415 ASSERT_EQ(1u, connection_->output_list()->size()); |
| 414 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); | 416 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); |
| 415 DataFrame* df = *i++; | 417 DataFrame* df = *i++; |
| 416 | 418 |
| 417 { | 419 { |
| 418 InSequence s; | 420 InSequence s; |
| 419 EXPECT_CALL(*spdy_framer_visitor_, | 421 EXPECT_CALL(*spdy_framer_visitor_, |
| 420 OnSynStream(stream_id, 0, _, false, false, _)) | 422 OnSynStream(stream_id, 0, _, false, false, _)) |
| 421 .WillOnce(SaveArg<5>(&actual_header_block)); | 423 .WillOnce(SaveArg<5>(&actual_header_block)); |
| 422 } | 424 } |
| 423 | 425 |
| 424 spdy_framer_->ProcessInput(df->data, df->size); | 426 spdy_framer_->ProcessInput(df->data, df->size); |
| 425 ASSERT_EQ(1, spdy_framer_->frames_received()); | 427 ASSERT_EQ(1, spdy_framer_->frames_received()); |
| 426 ASSERT_EQ(5u, actual_header_block.size()); | 428 ASSERT_EQ(5u, actual_header_block.size()); |
| 427 ASSERT_EQ("GET", actual_header_block[":method"]); | 429 ASSERT_EQ("GET", static_cast<StringPiece>(actual_header_block[":method"])); |
| 428 ASSERT_EQ("HTTP/1.1", actual_header_block[":version"]); | 430 ASSERT_EQ("HTTP/1.1", |
| 429 ASSERT_EQ("/path", actual_header_block[":path"]); | 431 static_cast<StringPiece>(actual_header_block[":version"])); |
| 430 ASSERT_EQ("www.example.com", actual_header_block[":host"]); | 432 ASSERT_EQ("/path", static_cast<StringPiece>(actual_header_block[":path"])); |
| 431 ASSERT_EQ("value1", actual_header_block["key1"]); | 433 ASSERT_EQ("www.example.com", |
| 434 static_cast<StringPiece>(actual_header_block[":host"])); |
| 435 ASSERT_EQ("value1", static_cast<StringPiece>(actual_header_block["key1"])); |
| 432 } | 436 } |
| 433 | 437 |
| 434 TEST_P(SpdySMProxyTest, SendSynReply) { | 438 TEST_P(SpdySMProxyTest, SendSynReply) { |
| 435 uint32 stream_id = 82; | 439 uint32 stream_id = 82; |
| 436 BalsaHeaders headers; | 440 BalsaHeaders headers; |
| 437 SpdyHeaderBlock actual_header_block; | 441 SpdyHeaderBlock actual_header_block; |
| 438 headers.AppendHeader("key1", "value1"); | 442 headers.AppendHeader("key1", "value1"); |
| 439 headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", "OK"); | 443 headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", "OK"); |
| 440 | 444 |
| 441 interface_->SendSynReply(stream_id, headers); | 445 interface_->SendSynReply(stream_id, headers); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 453 EXPECT_CALL(*spdy_framer_visitor_, | 457 EXPECT_CALL(*spdy_framer_visitor_, |
| 454 OnHeaders(stream_id, /*has_priority=*/false, _, _, _, | 458 OnHeaders(stream_id, /*has_priority=*/false, _, _, _, |
| 455 /*fin=*/false, _)) | 459 /*fin=*/false, _)) |
| 456 .WillOnce(SaveArg<6>(&actual_header_block)); | 460 .WillOnce(SaveArg<6>(&actual_header_block)); |
| 457 } | 461 } |
| 458 } | 462 } |
| 459 | 463 |
| 460 spdy_framer_->ProcessInput(df->data, df->size); | 464 spdy_framer_->ProcessInput(df->data, df->size); |
| 461 ASSERT_EQ(1, spdy_framer_->frames_received()); | 465 ASSERT_EQ(1, spdy_framer_->frames_received()); |
| 462 ASSERT_EQ(3u, actual_header_block.size()); | 466 ASSERT_EQ(3u, actual_header_block.size()); |
| 463 ASSERT_EQ("200 OK", actual_header_block[":status"]); | 467 ASSERT_EQ("200 OK", static_cast<StringPiece>(actual_header_block[":status"])); |
| 464 ASSERT_EQ("HTTP/1.1", actual_header_block[":version"]); | 468 ASSERT_EQ("HTTP/1.1", |
| 465 ASSERT_EQ("value1", actual_header_block["key1"]); | 469 static_cast<StringPiece>(actual_header_block[":version"])); |
| 470 ASSERT_EQ("value1", static_cast<StringPiece>(actual_header_block["key1"])); |
| 466 } | 471 } |
| 467 | 472 |
| 468 TEST_P(SpdySMProxyTest, SendDataFrame) { | 473 TEST_P(SpdySMProxyTest, SendDataFrame) { |
| 469 uint32 stream_id = 133; | 474 uint32 stream_id = 133; |
| 470 SpdyDataFlags flags = DATA_FLAG_NONE; | 475 SpdyDataFlags flags = DATA_FLAG_NONE; |
| 471 const char* actual_data; | 476 const char* actual_data; |
| 472 size_t actual_size; | 477 size_t actual_size; |
| 473 | 478 |
| 474 interface_->SendDataFrame(stream_id, "hello", 5, flags, true); | 479 interface_->SendDataFrame(stream_id, "hello", 5, flags, true); |
| 475 | 480 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 600 |
| 596 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); | 601 std::list<DataFrame*>::const_iterator i = connection_->output_list()->begin(); |
| 597 DataFrame* df = *i++; | 602 DataFrame* df = *i++; |
| 598 spdy_framer_->ProcessInput(df->data, df->size); | 603 spdy_framer_->ProcessInput(df->data, df->size); |
| 599 checkpoint.Call(0); | 604 checkpoint.Call(0); |
| 600 df = *i++; | 605 df = *i++; |
| 601 spdy_framer_->ProcessInput(df->data, df->size); | 606 spdy_framer_->ProcessInput(df->data, df->size); |
| 602 | 607 |
| 603 ASSERT_EQ(2, spdy_framer_->frames_received()); | 608 ASSERT_EQ(2, spdy_framer_->frames_received()); |
| 604 ASSERT_EQ(2u, actual_header_block.size()); | 609 ASSERT_EQ(2u, actual_header_block.size()); |
| 605 ASSERT_EQ("404 Not Found", actual_header_block["status"]); | 610 ASSERT_EQ("404 Not Found", |
| 606 ASSERT_EQ("HTTP/1.1", actual_header_block["version"]); | 611 static_cast<StringPiece>(actual_header_block["status"])); |
| 612 ASSERT_EQ("HTTP/1.1", |
| 613 static_cast<StringPiece>(actual_header_block["version"])); |
| 607 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); | 614 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); |
| 608 } | 615 } |
| 609 | 616 |
| 610 } // namespace | 617 } // namespace |
| 611 | 618 |
| 612 } // namespace net | 619 } // namespace net |
| OLD | NEW |