| 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/quic/core/quic_spdy_stream.h" | 5 #include "net/quic/core/quic_spdy_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 | 964 |
| 965 // Writing trailers will send a FIN, but not close the write side of the | 965 // Writing trailers will send a FIN, but not close the write side of the |
| 966 // stream as there are queued bytes. | 966 // stream as there are queued bytes. |
| 967 EXPECT_CALL(*session_, WriteHeadersMock(_, _, true, _, _)); | 967 EXPECT_CALL(*session_, WriteHeadersMock(_, _, true, _, _)); |
| 968 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr); | 968 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr); |
| 969 EXPECT_TRUE(stream_->fin_sent()); | 969 EXPECT_TRUE(stream_->fin_sent()); |
| 970 if (!session_->force_hol_blocking()) { | 970 if (!session_->force_hol_blocking()) { |
| 971 EXPECT_FALSE(stream_->write_side_closed()); | 971 EXPECT_FALSE(stream_->write_side_closed()); |
| 972 } | 972 } |
| 973 | 973 |
| 974 if (!FLAGS_quic_close_stream_after_writing_queued_data) { | |
| 975 return; | |
| 976 } | |
| 977 // Writing the queued bytes will close the write side of the stream. | 974 // Writing the queued bytes will close the write side of the stream. |
| 978 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) | 975 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) |
| 979 .WillOnce(Return(QuicConsumedData(1, false))); | 976 .WillOnce(Return(QuicConsumedData(1, false))); |
| 980 stream_->OnCanWrite(); | 977 stream_->OnCanWrite(); |
| 981 EXPECT_TRUE(stream_->write_side_closed()); | 978 EXPECT_TRUE(stream_->write_side_closed()); |
| 982 } | 979 } |
| 983 | 980 |
| 984 TEST_P(QuicSpdyStreamTest, WritingTrailersAfterFIN) { | 981 TEST_P(QuicSpdyStreamTest, WritingTrailersAfterFIN) { |
| 985 // Test that it is not possible to write Trailers after a FIN has been sent. | 982 // Test that it is not possible to write Trailers after a FIN has been sent. |
| 986 Initialize(kShouldProcessData); | 983 Initialize(kShouldProcessData); |
| 987 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) | 984 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) |
| 988 .Times(AnyNumber()) | 985 .Times(AnyNumber()) |
| 989 .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData)); | 986 .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData)); |
| 990 | 987 |
| 991 // Write the initial headers, with a FIN. | 988 // Write the initial headers, with a FIN. |
| 992 EXPECT_CALL(*session_, WriteHeadersMock(_, _, _, _, _)); | 989 EXPECT_CALL(*session_, WriteHeadersMock(_, _, _, _, _)); |
| 993 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/true, nullptr); | 990 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/true, nullptr); |
| 994 EXPECT_TRUE(stream_->fin_sent()); | 991 EXPECT_TRUE(stream_->fin_sent()); |
| 995 | 992 |
| 996 // Writing Trailers should fail, as the FIN has already been sent. | 993 // Writing Trailers should fail, as the FIN has already been sent. |
| 997 // populated with the number of body bytes written. | 994 // populated with the number of body bytes written. |
| 998 EXPECT_QUIC_BUG(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), | 995 EXPECT_QUIC_BUG(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), |
| 999 "Trailers cannot be sent after a FIN"); | 996 "Trailers cannot be sent after a FIN"); |
| 1000 } | 997 } |
| 1001 | 998 |
| 1002 } // namespace | 999 } // namespace |
| 1003 } // namespace test | 1000 } // namespace test |
| 1004 } // namespace net | 1001 } // namespace net |
| OLD | NEW |