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

Unified Diff: net/tools/quic/quic_simple_server_stream.cc

Issue 2421173003: Allowing the SimpleQuicBackend to send an early response. Test-only change. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_simple_server_stream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_simple_server_stream.cc
diff --git a/net/tools/quic/quic_simple_server_stream.cc b/net/tools/quic/quic_simple_server_stream.cc
index b9dd897fcd349605144c3c8841175d6a46ada551..8b10b752f12515b3b6719cc4f5160ea3d7b1270b 100644
--- a/net/tools/quic/quic_simple_server_stream.cc
+++ b/net/tools/quic/quic_simple_server_stream.cc
@@ -28,7 +28,9 @@ namespace net {
QuicSimpleServerStream::QuicSimpleServerStream(QuicStreamId id,
QuicSpdySession* session)
- : QuicSpdyStream(id, session), content_length_(-1) {}
+ : QuicSpdyStream(id, session),
+ content_length_(-1),
+ response_started_(false) {}
QuicSimpleServerStream::~QuicSimpleServerStream() {}
@@ -103,21 +105,10 @@ void QuicSimpleServerStream::OnDataAvailable() {
return;
}
- if (request_headers_.empty()) {
- DVLOG(1) << "Request headers empty.";
- SendErrorResponse();
- return;
- }
-
- if (content_length_ > 0 &&
- static_cast<uint64_t>(content_length_) != body_.size()) {
- DVLOG(1) << "Content length (" << content_length_ << ") != body size ("
- << body_.size() << ").";
- SendErrorResponse();
- return;
+ // Subclass could have manually invoked SendResponse earlier.
+ if (!response_started_) {
+ SendResponse();
}
-
- SendResponse();
}
void QuicSimpleServerStream::PushResponse(
@@ -136,6 +127,23 @@ void QuicSimpleServerStream::PushResponse(
}
void QuicSimpleServerStream::SendResponse() {
+ DCHECK(!response_started_);
+ response_started_ = true;
+
+ if (request_headers_.empty()) {
+ DVLOG(1) << "Request headers empty.";
+ SendErrorResponse();
+ return;
+ }
+
+ if (content_length_ > 0 &&
+ static_cast<uint64_t>(content_length_) != body_.size()) {
+ DVLOG(1) << "Content length (" << content_length_ << ") != body size ("
+ << body_.size() << ").";
+ SendErrorResponse();
+ return;
+ }
+
if (!base::ContainsKey(request_headers_, ":authority") ||
!base::ContainsKey(request_headers_, ":path")) {
DVLOG(1) << "Request headers do not contain :authority or :path.";
« no previous file with comments | « net/tools/quic/quic_simple_server_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698