| OLD | NEW |
| 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/tools/quic/quic_reliable_server_stream.h" | 5 #include "net/tools/quic/quic_reliable_server_stream.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "net/quic/quic_spdy_compressor.h" | |
| 9 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 9 #include "net/quic/test_tools/quic_test_utils.h" |
| 11 #include "net/tools/flip_server/epoll_server.h" | 10 #include "net/tools/flip_server/epoll_server.h" |
| 12 #include "net/tools/quic/quic_in_memory_cache.h" | 11 #include "net/tools/quic/quic_in_memory_cache.h" |
| 13 #include "net/tools/quic/quic_spdy_server_stream.h" | 12 #include "net/tools/quic/quic_spdy_server_stream.h" |
| 14 #include "net/tools/quic/spdy_utils.h" | 13 #include "net/tools/quic/spdy_utils.h" |
| 15 #include "net/tools/quic/test_tools/quic_test_utils.h" | 14 #include "net/tools/quic/test_tools/quic_test_utils.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 17 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 "POST", "https://www.google.com/", "HTTP/1.1"); | 53 "POST", "https://www.google.com/", "HTTP/1.1"); |
| 55 request_headers.ReplaceOrAppendHeader("content-length", "11"); | 54 request_headers.ReplaceOrAppendHeader("content-length", "11"); |
| 56 | 55 |
| 57 headers_string_ = SpdyUtils::SerializeRequestHeaders(request_headers); | 56 headers_string_ = SpdyUtils::SerializeRequestHeaders(request_headers); |
| 58 stream_.reset(new QuicSpdyServerStream(3, &session_)); | 57 stream_.reset(new QuicSpdyServerStream(3, &session_)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 QuicConsumedData ValidateHeaders(StringPiece headers) { | 60 QuicConsumedData ValidateHeaders(StringPiece headers) { |
| 62 headers_string_ = SpdyUtils::SerializeResponseHeaders( | 61 headers_string_ = SpdyUtils::SerializeResponseHeaders( |
| 63 response_headers_); | 62 response_headers_); |
| 64 QuicSpdyDecompressor decompressor; | |
| 65 TestDecompressorVisitor visitor; | |
| 66 | 63 |
| 67 // First the header id, then the compressed data. | 64 EXPECT_EQ(headers, headers_string_); |
| 68 EXPECT_EQ(1, headers[0]); | |
| 69 EXPECT_EQ(0, headers[1]); | |
| 70 EXPECT_EQ(0, headers[2]); | |
| 71 EXPECT_EQ(0, headers[3]); | |
| 72 EXPECT_EQ(static_cast<size_t>(headers.length() - 4), | |
| 73 decompressor.DecompressData(headers.substr(4), &visitor)); | |
| 74 | |
| 75 EXPECT_EQ(headers_string_, visitor.data()); | |
| 76 | 65 |
| 77 return QuicConsumedData(headers.size(), false); | 66 return QuicConsumedData(headers.size(), false); |
| 78 } | 67 } |
| 79 | 68 |
| 80 static void SetUpTestCase() { | 69 static void SetUpTestCase() { |
| 81 QuicInMemoryCache::GetInstance()->ResetForTests(); | 70 QuicInMemoryCache::GetInstance()->ResetForTests(); |
| 82 } | 71 } |
| 83 | 72 |
| 84 virtual void SetUp() { | 73 virtual void SetUp() { |
| 85 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); | 74 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 199 |
| 211 stream_->SendErrorResponse(); | 200 stream_->SendErrorResponse(); |
| 212 EXPECT_TRUE(stream_->read_side_closed()); | 201 EXPECT_TRUE(stream_->read_side_closed()); |
| 213 EXPECT_TRUE(stream_->write_side_closed()); | 202 EXPECT_TRUE(stream_->write_side_closed()); |
| 214 } | 203 } |
| 215 | 204 |
| 216 } // namespace | 205 } // namespace |
| 217 } // namespace test | 206 } // namespace test |
| 218 } // namespace tools | 207 } // namespace tools |
| 219 } // namespace net | 208 } // namespace net |
| OLD | NEW |