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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (response->response_type() == QuicInMemoryCache::IGNORE_REQUEST) { | 161 if (response->response_type() == QuicInMemoryCache::IGNORE_REQUEST) { |
162 DVLOG(1) << "Special response: ignoring request."; | 162 DVLOG(1) << "Special response: ignoring request."; |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 // Examing response status, if it was not pure integer as typical h2 response | 166 // Examing response status, if it was not pure integer as typical h2 response |
167 // status, send error response. | 167 // status, send error response. |
168 string request_url = request_headers_[":authority"].as_string() + | 168 string request_url = request_headers_[":authority"].as_string() + |
169 request_headers_[":path"].as_string(); | 169 request_headers_[":path"].as_string(); |
170 int response_code; | 170 int response_code; |
171 SpdyHeaderBlock response_headers = response->headers(); | 171 const SpdyHeaderBlock& response_headers = response->headers(); |
172 if (!ParseHeaderStatusCode(&response_headers, &response_code)) { | 172 if (!ParseHeaderStatusCode(response_headers, &response_code)) { |
173 DVLOG(1) << "Illegal (non-integer) response :status from cache: " | 173 LOG(WARNING) << "Illegal (non-integer) response :status from cache: " |
174 << response_headers[":status"].as_string() << " for request " | 174 << response_headers.GetHeader(":status") << " for request " |
175 << request_url; | 175 << request_url; |
176 SendErrorResponse(); | 176 SendErrorResponse(); |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 if (id() % 2 == 0) { | 180 if (id() % 2 == 0) { |
181 // A server initiated stream is only used for a server push response, | 181 // A server initiated stream is only used for a server push response, |
182 // and only 200 and 30X response codes are supported for server push. | 182 // and only 200 and 30X response codes are supported for server push. |
183 // This behavior mirrors the HTTP/2 implementation. | 183 // This behavior mirrors the HTTP/2 implementation. |
184 bool is_redirection = response_code / 100 == 3; | 184 bool is_redirection = response_code / 100 == 3; |
185 if (response_code != 200 && !is_redirection) { | 185 if (response_code != 200 && !is_redirection) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 DVLOG(1) << "Writing trailers (fin = true): " | 262 DVLOG(1) << "Writing trailers (fin = true): " |
263 << response_trailers.DebugString(); | 263 << response_trailers.DebugString(); |
264 WriteTrailers(response_trailers, nullptr); | 264 WriteTrailers(response_trailers, nullptr); |
265 } | 265 } |
266 | 266 |
267 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 267 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
268 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 268 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
269 "file not found"; | 269 "file not found"; |
270 | 270 |
271 } // namespace net | 271 } // namespace net |
OLD | NEW |