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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 // Examing response status, if it was not pure integer as typical h2 response | 171 // Examing response status, if it was not pure integer as typical h2 response |
172 // status, send error response. | 172 // status, send error response. |
173 string request_url = request_headers_[":authority"].as_string() + | 173 string request_url = request_headers_[":authority"].as_string() + |
174 request_headers_[":path"].as_string(); | 174 request_headers_[":path"].as_string(); |
175 int response_code; | 175 int response_code; |
176 const SpdyHeaderBlock& response_headers = response->headers(); | 176 const SpdyHeaderBlock& response_headers = response->headers(); |
177 if (!ParseHeaderStatusCode(response_headers, &response_code)) { | 177 if (!ParseHeaderStatusCode(response_headers, &response_code)) { |
178 LOG(WARNING) << "Illegal (non-integer) response :status from cache: " | 178 auto status = response_headers.find(":status"); |
179 << response_headers.GetHeader(":status") << " for request " | 179 if (status == response_headers.end()) { |
180 << request_url; | 180 LOG(WARNING) << ":status not present in response from cache for request " |
| 181 << request_url; |
| 182 } else { |
| 183 LOG(WARNING) << "Illegal (non-integer) response :status from cache: " |
| 184 << status->second << " for request " << request_url; |
| 185 } |
181 SendErrorResponse(); | 186 SendErrorResponse(); |
182 return; | 187 return; |
183 } | 188 } |
184 | 189 |
185 if (id() % 2 == 0) { | 190 if (id() % 2 == 0) { |
186 // A server initiated stream is only used for a server push response, | 191 // A server initiated stream is only used for a server push response, |
187 // and only 200 and 30X response codes are supported for server push. | 192 // and only 200 and 30X response codes are supported for server push. |
188 // This behavior mirrors the HTTP/2 implementation. | 193 // This behavior mirrors the HTTP/2 implementation. |
189 bool is_redirection = response_code / 100 == 3; | 194 bool is_redirection = response_code / 100 == 3; |
190 if (response_code != 200 && !is_redirection) { | 195 if (response_code != 200 && !is_redirection) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 DVLOG(1) << "Writing trailers (fin = true): " | 273 DVLOG(1) << "Writing trailers (fin = true): " |
269 << response_trailers.DebugString(); | 274 << response_trailers.DebugString(); |
270 WriteTrailers(std::move(response_trailers), nullptr); | 275 WriteTrailers(std::move(response_trailers), nullptr); |
271 } | 276 } |
272 | 277 |
273 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 278 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
274 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 279 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
275 "file not found"; | 280 "file not found"; |
276 | 281 |
277 } // namespace net | 282 } // namespace net |
OLD | NEW |