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_spdy_client_stream.h" | 5 #include "net/tools/quic/quic_spdy_client_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "net/quic/quic_alarm.h" | 10 #include "net/quic/quic_alarm.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Reset(QUIC_BAD_APPLICATION_PAYLOAD); | 89 Reset(QUIC_BAD_APPLICATION_PAYLOAD); |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 ConsumeHeaderList(); | 93 ConsumeHeaderList(); |
94 DVLOG(1) << "headers complete for stream " << id(); | 94 DVLOG(1) << "headers complete for stream " << id(); |
95 | 95 |
96 session_->OnInitialHeadersComplete(id(), response_headers_); | 96 session_->OnInitialHeadersComplete(id(), response_headers_); |
97 } | 97 } |
98 | 98 |
99 void QuicSpdyClientStream::OnTrailingHeadersComplete( | 99 void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin, |
100 bool fin, | 100 size_t frame_len) { |
101 size_t frame_len, | 101 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len); |
102 const QuicHeaderList& header_list) { | |
103 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len, header_list); | |
104 MarkTrailersConsumed(decompressed_trailers().length()); | 102 MarkTrailersConsumed(decompressed_trailers().length()); |
105 } | 103 } |
106 | 104 |
107 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id, | 105 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id, |
108 size_t frame_len) { | 106 size_t frame_len) { |
109 header_bytes_read_ += frame_len; | 107 header_bytes_read_ += frame_len; |
110 int64_t content_length = -1; | 108 int64_t content_length = -1; |
111 SpdyHeaderBlock promise_headers; | 109 SpdyHeaderBlock promise_headers; |
112 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), | 110 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), |
113 decompressed_headers().length(), &content_length, | 111 decompressed_headers().length(), &content_length, |
(...skipping 20 matching lines...) Expand all Loading... |
134 SpdyHeaderBlock promise_headers; | 132 SpdyHeaderBlock promise_headers; |
135 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length, | 133 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length, |
136 &promise_headers)) { | 134 &promise_headers)) { |
137 DLOG(ERROR) << "Failed to parse promise headers: " | 135 DLOG(ERROR) << "Failed to parse promise headers: " |
138 << header_list.DebugString(); | 136 << header_list.DebugString(); |
139 Reset(QUIC_BAD_APPLICATION_PAYLOAD); | 137 Reset(QUIC_BAD_APPLICATION_PAYLOAD); |
140 return; | 138 return; |
141 } | 139 } |
142 | 140 |
143 session_->HandlePromised(id(), promised_id, promise_headers); | 141 session_->HandlePromised(id(), promised_id, promise_headers); |
144 if (visitor() != nullptr) { | |
145 visitor()->OnPromiseHeadersComplete(promised_id, frame_len); | |
146 } | |
147 } | 142 } |
148 | 143 |
149 void QuicSpdyClientStream::OnDataAvailable() { | 144 void QuicSpdyClientStream::OnDataAvailable() { |
150 if (FLAGS_quic_supports_push_promise) { | 145 if (FLAGS_quic_supports_push_promise) { |
151 // For push streams, visitor will not be set until the rendezvous | 146 // For push streams, visitor will not be set until the rendezvous |
152 // between server promise and client request is complete. | 147 // between server promise and client request is complete. |
153 if (visitor() == nullptr) | 148 if (visitor() == nullptr) |
154 return; | 149 return; |
155 } | 150 } |
156 | 151 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 bytes_sent += header_bytes_written_; | 184 bytes_sent += header_bytes_written_; |
190 | 185 |
191 if (!body.empty()) { | 186 if (!body.empty()) { |
192 WriteOrBufferData(body, fin, nullptr); | 187 WriteOrBufferData(body, fin, nullptr); |
193 } | 188 } |
194 | 189 |
195 return bytes_sent; | 190 return bytes_sent; |
196 } | 191 } |
197 | 192 |
198 } // namespace net | 193 } // namespace net |
OLD | NEW |