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