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 25 matching lines...) Expand all Loading... |
36 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len); | 36 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len); |
37 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), | 37 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), |
38 decompressed_headers().length(), | 38 decompressed_headers().length(), |
39 &content_length_, &request_headers_)) { | 39 &content_length_, &request_headers_)) { |
40 DVLOG(1) << "Invalid headers"; | 40 DVLOG(1) << "Invalid headers"; |
41 SendErrorResponse(); | 41 SendErrorResponse(); |
42 } | 42 } |
43 MarkHeadersConsumed(decompressed_headers().length()); | 43 MarkHeadersConsumed(decompressed_headers().length()); |
44 } | 44 } |
45 | 45 |
| 46 void QuicSimpleServerStream::OnInitialHeadersComplete( |
| 47 bool fin, |
| 48 size_t frame_len, |
| 49 const QuicHeaderList& header_list) { |
| 50 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); |
| 51 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_, |
| 52 &request_headers_)) { |
| 53 DVLOG(1) << "Invalid headers"; |
| 54 SendErrorResponse(); |
| 55 } |
| 56 ConsumeHeaderList(); |
| 57 } |
| 58 |
46 void QuicSimpleServerStream::OnTrailingHeadersComplete(bool fin, | 59 void QuicSimpleServerStream::OnTrailingHeadersComplete(bool fin, |
47 size_t frame_len) { | 60 size_t frame_len) { |
48 QUIC_BUG << "Server does not support receiving Trailers."; | 61 QUIC_BUG << "Server does not support receiving Trailers."; |
49 SendErrorResponse(); | 62 SendErrorResponse(); |
50 } | 63 } |
51 | 64 |
| 65 void QuicSimpleServerStream::OnTrailingHeadersComplete( |
| 66 bool fin, |
| 67 size_t frame_len, |
| 68 const QuicHeaderList& header_list) { |
| 69 QUIC_BUG << "Server does not support receiving Trailers."; |
| 70 SendErrorResponse(); |
| 71 } |
| 72 |
52 void QuicSimpleServerStream::OnDataAvailable() { | 73 void QuicSimpleServerStream::OnDataAvailable() { |
53 while (HasBytesToRead()) { | 74 while (HasBytesToRead()) { |
54 struct iovec iov; | 75 struct iovec iov; |
55 if (GetReadableRegions(&iov, 1) == 0) { | 76 if (GetReadableRegions(&iov, 1) == 0) { |
56 // No more data to read. | 77 // No more data to read. |
57 break; | 78 break; |
58 } | 79 } |
59 DVLOG(1) << "Processed " << iov.iov_len << " bytes for stream " << id(); | 80 DVLOG(1) << "Processed " << iov.iov_len << " bytes for stream " << id(); |
60 body_.append(static_cast<char*>(iov.iov_base), iov.iov_len); | 81 body_.append(static_cast<char*>(iov.iov_base), iov.iov_len); |
61 | 82 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 DVLOG(1) << "Writing trailers (fin = true): " | 262 DVLOG(1) << "Writing trailers (fin = true): " |
242 << response_trailers.DebugString(); | 263 << response_trailers.DebugString(); |
243 WriteTrailers(response_trailers, nullptr); | 264 WriteTrailers(response_trailers, nullptr); |
244 } | 265 } |
245 | 266 |
246 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 267 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
247 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 268 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
248 "file not found"; | 269 "file not found"; |
249 | 270 |
250 } // namespace net | 271 } // namespace net |
OLD | NEW |