| 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 <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Change the stream state to emulate a client request. | 129 // Change the stream state to emulate a client request. |
| 130 request_headers_ = std::move(push_request_headers); | 130 request_headers_ = std::move(push_request_headers); |
| 131 content_length_ = 0; | 131 content_length_ = 0; |
| 132 DVLOG(1) << "Stream " << id() << ": Ready to receive server push response."; | 132 DVLOG(1) << "Stream " << id() << ": Ready to receive server push response."; |
| 133 | 133 |
| 134 // Set as if stream decompresed the headers and received fin. | 134 // Set as if stream decompresed the headers and received fin. |
| 135 QuicSpdyStream::OnInitialHeadersComplete(/*fin=*/true, 0); | 135 QuicSpdyStream::OnInitialHeadersComplete(/*fin=*/true, 0); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void QuicSimpleServerStream::SendResponse() { | 138 void QuicSimpleServerStream::SendResponse() { |
| 139 if (!ContainsKey(request_headers_, ":authority") || | 139 if (!base::ContainsKey(request_headers_, ":authority") || |
| 140 !ContainsKey(request_headers_, ":path")) { | 140 !base::ContainsKey(request_headers_, ":path")) { |
| 141 DVLOG(1) << "Request headers do not contain :authority or :path."; | 141 DVLOG(1) << "Request headers do not contain :authority or :path."; |
| 142 SendErrorResponse(); | 142 SendErrorResponse(); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Find response in cache. If not found, send error response. | 146 // Find response in cache. If not found, send error response. |
| 147 const QuicInMemoryCache::Response* response = | 147 const QuicInMemoryCache::Response* response = |
| 148 QuicInMemoryCache::GetInstance()->GetResponse( | 148 QuicInMemoryCache::GetInstance()->GetResponse( |
| 149 request_headers_[":authority"], request_headers_[":path"]); | 149 request_headers_[":authority"], request_headers_[":path"]); |
| 150 if (response == nullptr) { | 150 if (response == nullptr) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 DVLOG(1) << "Writing trailers (fin = true): " | 264 DVLOG(1) << "Writing trailers (fin = true): " |
| 265 << response_trailers.DebugString(); | 265 << response_trailers.DebugString(); |
| 266 WriteTrailers(std::move(response_trailers), nullptr); | 266 WriteTrailers(std::move(response_trailers), nullptr); |
| 267 } | 267 } |
| 268 | 268 |
| 269 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 269 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
| 270 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 270 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
| 271 "file not found"; | 271 "file not found"; |
| 272 | 272 |
| 273 } // namespace net | 273 } // namespace net |
| OLD | NEW |