| 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_spdy_server_stream.h" | 5 #include "net/tools/quic/quic_spdy_server_stream.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "net/quic/quic_session.h" | 8 #include "net/quic/quic_session.h" |
| 9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
| 10 #include "net/tools/quic/quic_in_memory_cache.h" | 10 #include "net/tools/quic/quic_in_memory_cache.h" |
| 11 #include "net/tools/quic/spdy_utils.h" | 11 #include "net/tools/quic/spdy_utils.h" |
| 12 #include "url/gurl.h" |
| 12 | 13 |
| 13 using base::StringPiece; | 14 using base::StringPiece; |
| 14 using std::string; | 15 using std::string; |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 namespace tools { | 18 namespace tools { |
| 18 | 19 |
| 19 static const size_t kHeaderBufInitialSize = 4096; | 20 static const size_t kHeaderBufInitialSize = 4096; |
| 20 | 21 |
| 21 QuicSpdyServerStream::QuicSpdyServerStream(QuicStreamId id, | 22 QuicSpdyServerStream::QuicSpdyServerStream(QuicStreamId id, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 size_t delta = read_buf_len - len; | 84 size_t delta = read_buf_len - len; |
| 84 if (delta > 0) { | 85 if (delta > 0) { |
| 85 body_.append(data + len, delta); | 86 body_.append(data + len, delta); |
| 86 } | 87 } |
| 87 | 88 |
| 88 request_headers_received_ = true; | 89 request_headers_received_ = true; |
| 89 } | 90 } |
| 90 | 91 |
| 91 void QuicSpdyServerStream::SendResponse() { | 92 void QuicSpdyServerStream::SendResponse() { |
| 92 // Find response in cache. If not found, send error response. | 93 // Find response in cache. If not found, send error response. |
| 94 GURL url(headers_.request_uri().as_string()); |
| 95 if (!url.is_valid()) { |
| 96 SendErrorResponse(); |
| 97 return; |
| 98 } |
| 93 const QuicInMemoryCache::Response* response = | 99 const QuicInMemoryCache::Response* response = |
| 94 QuicInMemoryCache::GetInstance()->GetResponse(headers_); | 100 QuicInMemoryCache::GetInstance()->GetResponse( |
| 101 url.host(), |
| 102 url.PathForRequest()); |
| 95 if (response == nullptr) { | 103 if (response == nullptr) { |
| 96 SendErrorResponse(); | 104 SendErrorResponse(); |
| 97 return; | 105 return; |
| 98 } | 106 } |
| 99 | 107 |
| 100 if (response->response_type() == QuicInMemoryCache::CLOSE_CONNECTION) { | 108 if (response->response_type() == QuicInMemoryCache::CLOSE_CONNECTION) { |
| 101 DVLOG(1) << "Special response: closing connection."; | 109 DVLOG(1) << "Special response: closing connection."; |
| 102 CloseConnection(QUIC_NO_ERROR); | 110 CloseConnection(QUIC_NO_ERROR); |
| 103 return; | 111 return; |
| 104 } | 112 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 134 | 142 |
| 135 WriteHeaders(header_block, body.empty(), nullptr); | 143 WriteHeaders(header_block, body.empty(), nullptr); |
| 136 | 144 |
| 137 if (!body.empty()) { | 145 if (!body.empty()) { |
| 138 WriteOrBufferData(body, true, nullptr); | 146 WriteOrBufferData(body, true, nullptr); |
| 139 } | 147 } |
| 140 } | 148 } |
| 141 | 149 |
| 142 } // namespace tools | 150 } // namespace tools |
| 143 } // namespace net | 151 } // namespace net |
| OLD | NEW |