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

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

Issue 2629723003: Revert of Add quic_logging (Closed)
Patch Set: Created 3 years, 11 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 <utility> 7 #include <utility>
8 8
9 #include "base/logging.h"
9 #include "base/stl_util.h" 10 #include "base/stl_util.h"
10 #include "net/quic/core/quic_alarm.h" 11 #include "net/quic/core/quic_alarm.h"
11 #include "net/quic/core/quic_client_promised_info.h" 12 #include "net/quic/core/quic_client_promised_info.h"
12 #include "net/quic/core/spdy_utils.h" 13 #include "net/quic/core/spdy_utils.h"
13 #include "net/quic/platform/api/quic_logging.h"
14 #include "net/spdy/spdy_protocol.h" 14 #include "net/spdy/spdy_protocol.h"
15 #include "net/tools/quic/quic_client_session.h" 15 #include "net/tools/quic/quic_client_session.h"
16 16
17 using base::StringPiece; 17 using base::StringPiece;
18 using std::string; 18 using std::string;
19 19
20 namespace net { 20 namespace net {
21 21
22 QuicSpdyClientStream::QuicSpdyClientStream(QuicStreamId id, 22 QuicSpdyClientStream::QuicSpdyClientStream(QuicStreamId id,
23 QuicClientSession* session) 23 QuicClientSession* session)
24 : QuicSpdyStream(id, session), 24 : QuicSpdyStream(id, session),
25 content_length_(-1), 25 content_length_(-1),
26 response_code_(0), 26 response_code_(0),
27 header_bytes_read_(0), 27 header_bytes_read_(0),
28 header_bytes_written_(0), 28 header_bytes_written_(0),
29 session_(session), 29 session_(session),
30 has_preliminary_headers_(false) {} 30 has_preliminary_headers_(false) {}
31 31
32 QuicSpdyClientStream::~QuicSpdyClientStream() {} 32 QuicSpdyClientStream::~QuicSpdyClientStream() {}
33 33
34 void QuicSpdyClientStream::OnStreamFrame(const QuicStreamFrame& frame) { 34 void QuicSpdyClientStream::OnStreamFrame(const QuicStreamFrame& frame) {
35 if (!allow_bidirectional_data() && !write_side_closed()) { 35 if (!allow_bidirectional_data() && !write_side_closed()) {
36 QUIC_DLOG(INFO) << "Got a response before the request was complete. " 36 DVLOG(1) << "Got a response before the request was complete. "
37 << "Aborting request."; 37 << "Aborting request.";
38 CloseWriteSide(); 38 CloseWriteSide();
39 } 39 }
40 QuicSpdyStream::OnStreamFrame(frame); 40 QuicSpdyStream::OnStreamFrame(frame);
41 } 41 }
42 42
43 void QuicSpdyClientStream::OnInitialHeadersComplete( 43 void QuicSpdyClientStream::OnInitialHeadersComplete(
44 bool fin, 44 bool fin,
45 size_t frame_len, 45 size_t frame_len,
46 const QuicHeaderList& header_list) { 46 const QuicHeaderList& header_list) {
47 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); 47 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list);
48 48
49 DCHECK(headers_decompressed()); 49 DCHECK(headers_decompressed());
50 header_bytes_read_ += frame_len; 50 header_bytes_read_ += frame_len;
51 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_, 51 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_,
52 &response_headers_)) { 52 &response_headers_)) {
53 QUIC_DLOG(ERROR) << "Failed to parse header list: " 53 DLOG(ERROR) << "Failed to parse header list: " << header_list.DebugString();
54 << header_list.DebugString();
55 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 54 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
56 return; 55 return;
57 } 56 }
58 57
59 if (!ParseHeaderStatusCode(response_headers_, &response_code_)) { 58 if (!ParseHeaderStatusCode(response_headers_, &response_code_)) {
60 QUIC_DLOG(ERROR) << "Received invalid response code: " 59 DLOG(ERROR) << "Received invalid response code: "
61 << response_headers_[":status"].as_string(); 60 << response_headers_[":status"].as_string();
62 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 61 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
63 return; 62 return;
64 } 63 }
65 64
66 if (FLAGS_quic_restart_flag_quic_supports_100_continue && 65 if (FLAGS_quic_restart_flag_quic_supports_100_continue &&
67 response_code_ == 100 && !has_preliminary_headers_) { 66 response_code_ == 100 && !has_preliminary_headers_) {
68 // These are preliminary 100 Continue headers, not the actual response 67 // These are preliminary 100 Continue headers, not the actual response
69 // headers. 68 // headers.
70 set_headers_decompressed(false); 69 set_headers_decompressed(false);
71 has_preliminary_headers_ = true; 70 has_preliminary_headers_ = true;
72 preliminary_headers_ = std::move(response_headers_); 71 preliminary_headers_ = std::move(response_headers_);
73 } 72 }
74 73
75 ConsumeHeaderList(); 74 ConsumeHeaderList();
76 QUIC_DVLOG(1) << "headers complete for stream " << id(); 75 DVLOG(1) << "headers complete for stream " << id();
77 76
78 session_->OnInitialHeadersComplete(id(), response_headers_); 77 session_->OnInitialHeadersComplete(id(), response_headers_);
79 } 78 }
80 79
81 void QuicSpdyClientStream::OnTrailingHeadersComplete( 80 void QuicSpdyClientStream::OnTrailingHeadersComplete(
82 bool fin, 81 bool fin,
83 size_t frame_len, 82 size_t frame_len,
84 const QuicHeaderList& header_list) { 83 const QuicHeaderList& header_list) {
85 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len, header_list); 84 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len, header_list);
86 MarkTrailersConsumed(); 85 MarkTrailersConsumed();
87 } 86 }
88 87
89 void QuicSpdyClientStream::OnPromiseHeaderList( 88 void QuicSpdyClientStream::OnPromiseHeaderList(
90 QuicStreamId promised_id, 89 QuicStreamId promised_id,
91 size_t frame_len, 90 size_t frame_len,
92 const QuicHeaderList& header_list) { 91 const QuicHeaderList& header_list) {
93 header_bytes_read_ += frame_len; 92 header_bytes_read_ += frame_len;
94 int64_t content_length = -1; 93 int64_t content_length = -1;
95 SpdyHeaderBlock promise_headers; 94 SpdyHeaderBlock promise_headers;
96 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length, 95 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length,
97 &promise_headers)) { 96 &promise_headers)) {
98 QUIC_DLOG(ERROR) << "Failed to parse promise headers: " 97 DLOG(ERROR) << "Failed to parse promise headers: "
99 << header_list.DebugString(); 98 << header_list.DebugString();
100 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 99 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
101 return; 100 return;
102 } 101 }
103 102
104 session_->HandlePromised(id(), promised_id, promise_headers); 103 session_->HandlePromised(id(), promised_id, promise_headers);
105 if (visitor() != nullptr) { 104 if (visitor() != nullptr) {
106 visitor()->OnPromiseHeadersComplete(promised_id, frame_len); 105 visitor()->OnPromiseHeadersComplete(promised_id, frame_len);
107 } 106 }
108 } 107 }
109 108
110 void QuicSpdyClientStream::OnDataAvailable() { 109 void QuicSpdyClientStream::OnDataAvailable() {
111 // For push streams, visitor will not be set until the rendezvous 110 // For push streams, visitor will not be set until the rendezvous
112 // between server promise and client request is complete. 111 // between server promise and client request is complete.
113 if (visitor() == nullptr) 112 if (visitor() == nullptr)
114 return; 113 return;
115 114
116 while (HasBytesToRead()) { 115 while (HasBytesToRead()) {
117 struct iovec iov; 116 struct iovec iov;
118 if (GetReadableRegions(&iov, 1) == 0) { 117 if (GetReadableRegions(&iov, 1) == 0) {
119 // No more data to read. 118 // No more data to read.
120 break; 119 break;
121 } 120 }
122 QUIC_DVLOG(1) << "Client processed " << iov.iov_len << " bytes for stream " 121 DVLOG(1) << "Client processed " << iov.iov_len << " bytes for stream "
123 << id(); 122 << id();
124 data_.append(static_cast<char*>(iov.iov_base), iov.iov_len); 123 data_.append(static_cast<char*>(iov.iov_base), iov.iov_len);
125 124
126 if (content_length_ >= 0 && 125 if (content_length_ >= 0 &&
127 data_.size() > static_cast<uint64_t>(content_length_)) { 126 data_.size() > static_cast<uint64_t>(content_length_)) {
128 QUIC_DLOG(ERROR) << "Invalid content length (" << content_length_ 127 DLOG(ERROR) << "Invalid content length (" << content_length_
129 << ") with data of size " << data_.size(); 128 << ") with data of size " << data_.size();
130 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 129 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
131 return; 130 return;
132 } 131 }
133 MarkConsumed(iov.iov_len); 132 MarkConsumed(iov.iov_len);
134 } 133 }
135 if (sequencer()->IsClosed()) { 134 if (sequencer()->IsClosed()) {
136 OnFinRead(); 135 OnFinRead();
137 } else { 136 } else {
138 sequencer()->SetUnblocked(); 137 sequencer()->SetUnblocked();
139 } 138 }
(...skipping 11 matching lines...) Expand all
151 bytes_sent += header_bytes_written_; 150 bytes_sent += header_bytes_written_;
152 151
153 if (!body.empty()) { 152 if (!body.empty()) {
154 WriteOrBufferData(body, fin, nullptr); 153 WriteOrBufferData(body, fin, nullptr);
155 } 154 }
156 155
157 return bytes_sent; 156 return bytes_sent;
158 } 157 }
159 158
160 } // namespace net 159 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_stream.cc ('k') | net/tools/quic/quic_spdy_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698