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_simple_server_stream.h" | 5 #include "net/tools/quic/quic_simple_server_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 "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 content_length_ != static_cast<int>(body_.size())) { | 89 content_length_ != static_cast<int>(body_.size())) { |
90 DVLOG(1) << "Content length (" << content_length_ << ") != body size (" | 90 DVLOG(1) << "Content length (" << content_length_ << ") != body size (" |
91 << body_.size() << ")."; | 91 << body_.size() << ")."; |
92 SendErrorResponse(); | 92 SendErrorResponse(); |
93 return; | 93 return; |
94 } | 94 } |
95 | 95 |
96 SendResponse(); | 96 SendResponse(); |
97 } | 97 } |
98 | 98 |
| 99 void QuicSimpleServerStream::PushResponse( |
| 100 SpdyHeaderBlock push_request_headers) { |
| 101 if (id() % 2 != 0) { |
| 102 LOG(DFATAL) << "Client initiated stream shouldn't be used " |
| 103 << "as promised stream."; |
| 104 return; |
| 105 } |
| 106 // Change the stream state to emulate a client request. |
| 107 request_headers_ = push_request_headers; |
| 108 content_length_ = 0; |
| 109 DVLOG(1) << "Stream " << id() << ": Ready to receive server push response."; |
| 110 |
| 111 // Set as if stream decompresed the headers and received fin. |
| 112 QuicSpdyStream::OnInitialHeadersComplete(/*fin=*/true, 0); |
| 113 } |
| 114 |
99 void QuicSimpleServerStream::SendResponse() { | 115 void QuicSimpleServerStream::SendResponse() { |
100 if (!ContainsKey(request_headers_, ":authority") || | 116 if (!ContainsKey(request_headers_, ":authority") || |
101 !ContainsKey(request_headers_, ":path")) { | 117 !ContainsKey(request_headers_, ":path")) { |
102 DVLOG(1) << "Request headers do not contain :authority or :path."; | 118 DVLOG(1) << "Request headers do not contain :authority or :path."; |
103 SendErrorResponse(); | 119 SendErrorResponse(); |
104 return; | 120 return; |
105 } | 121 } |
106 | 122 |
107 // Find response in cache. If not found, send error response. | 123 // Find response in cache. If not found, send error response. |
108 const QuicInMemoryCache::Response* response = | 124 const QuicInMemoryCache::Response* response = |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Send the trailers. A FIN is always sent with trailers. | 220 // Send the trailers. A FIN is always sent with trailers. |
205 DVLOG(1) << "Writing trailers (fin = true): " | 221 DVLOG(1) << "Writing trailers (fin = true): " |
206 << response_trailers.DebugString(); | 222 << response_trailers.DebugString(); |
207 WriteTrailers(response_trailers, nullptr); | 223 WriteTrailers(response_trailers, nullptr); |
208 } | 224 } |
209 | 225 |
210 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 226 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
211 | 227 |
212 } // namespace tools | 228 } // namespace tools |
213 } // namespace net | 229 } // namespace net |
OLD | NEW |