Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Side by Side Diff: net/tools/quic/quic_spdy_client_stream.cc

Issue 1910593004: Plumbs new SpdyFramerVisitorInterface method handling through QUIC test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119562680
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 61 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
62 return; 62 return;
63 } 63 }
64 64
65 MarkHeadersConsumed(decompressed_headers().length()); 65 MarkHeadersConsumed(decompressed_headers().length());
66 DVLOG(1) << "headers complete for stream " << id(); 66 DVLOG(1) << "headers complete for stream " << id();
67 67
68 session_->OnInitialHeadersComplete(id(), response_headers_); 68 session_->OnInitialHeadersComplete(id(), response_headers_);
69 } 69 }
70 70
71 void QuicSpdyClientStream::OnInitialHeadersComplete(
72 bool fin,
73 size_t frame_len,
74 const QuicHeaderList& header_list) {
75 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list);
76
77 DCHECK(headers_decompressed());
78 header_bytes_read_ += frame_len;
79 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_,
80 &response_headers_)) {
81 DLOG(ERROR) << "Failed to parse header list: " << header_list.DebugString();
82 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
83 return;
84 }
85
86 if (!ParseHeaderStatusCode(&response_headers_, &response_code_)) {
87 DLOG(ERROR) << "Received invalid response code: "
88 << response_headers_[":status"].as_string();
89 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
90 return;
91 }
92
93 ConsumeHeaderList();
94 DVLOG(1) << "headers complete for stream " << id();
95
96 session_->OnInitialHeadersComplete(id(), response_headers_);
97 }
98
71 void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin, 99 void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin,
72 size_t frame_len) { 100 size_t frame_len) {
73 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len); 101 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len);
74 MarkTrailersConsumed(decompressed_trailers().length()); 102 MarkTrailersConsumed(decompressed_trailers().length());
75 } 103 }
76 104
77 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id, 105 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id,
78 size_t frame_len) { 106 size_t frame_len) {
79 header_bytes_read_ += frame_len; 107 header_bytes_read_ += frame_len;
80 int64_t content_length = -1; 108 int64_t content_length = -1;
81 SpdyHeaderBlock promise_headers; 109 SpdyHeaderBlock promise_headers;
82 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), 110 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(),
83 decompressed_headers().length(), &content_length, 111 decompressed_headers().length(), &content_length,
84 &promise_headers)) { 112 &promise_headers)) {
85 DLOG(ERROR) << "Failed to parse promise headers: " 113 DLOG(ERROR) << "Failed to parse promise headers: "
86 << decompressed_headers(); 114 << decompressed_headers();
87 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 115 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
88 return; 116 return;
89 } 117 }
90 MarkHeadersConsumed(decompressed_headers().length()); 118 MarkHeadersConsumed(decompressed_headers().length());
91 119
92 session_->HandlePromised(id(), promised_id, promise_headers); 120 session_->HandlePromised(id(), promised_id, promise_headers);
93 } 121 }
94 122
123 void QuicSpdyClientStream::OnPromiseHeaderList(
124 QuicStreamId promised_id,
125 size_t frame_len,
126 const QuicHeaderList& header_list) {
127 header_bytes_read_ += frame_len;
128 int64_t content_length = -1;
129 SpdyHeaderBlock promise_headers;
130 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length,
131 &promise_headers)) {
132 DLOG(ERROR) << "Failed to parse promise headers: "
133 << header_list.DebugString();
134 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
135 return;
136 }
137
138 session_->HandlePromised(id(), promised_id, promise_headers);
139 }
140
95 void QuicSpdyClientStream::OnDataAvailable() { 141 void QuicSpdyClientStream::OnDataAvailable() {
96 if (FLAGS_quic_supports_push_promise) { 142 if (FLAGS_quic_supports_push_promise) {
97 // For push streams, visitor will not be set until the rendezvous 143 // For push streams, visitor will not be set until the rendezvous
98 // between server promise and client request is complete. 144 // between server promise and client request is complete.
99 if (visitor() == nullptr) 145 if (visitor() == nullptr)
100 return; 146 return;
101 } 147 }
102 148
103 while (HasBytesToRead()) { 149 while (HasBytesToRead()) {
104 struct iovec iov; 150 struct iovec iov;
(...skipping 30 matching lines...) Expand all
135 bytes_sent += header_bytes_written_; 181 bytes_sent += header_bytes_written_;
136 182
137 if (!body.empty()) { 183 if (!body.empty()) {
138 WriteOrBufferData(body, fin, nullptr); 184 WriteOrBufferData(body, fin, nullptr);
139 } 185 }
140 186
141 return bytes_sent; 187 return bytes_sent;
142 } 188 }
143 189
144 } // namespace net 190 } // namespace net
OLDNEW
« net/quic/spdy_utils.h ('K') | « net/tools/quic/quic_spdy_client_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698