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 14 matching lines...) Expand all Loading... |
25 using std::string; | 25 using std::string; |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 | 28 |
29 QuicSimpleServerStream::QuicSimpleServerStream(QuicStreamId id, | 29 QuicSimpleServerStream::QuicSimpleServerStream(QuicStreamId id, |
30 QuicSpdySession* session) | 30 QuicSpdySession* session) |
31 : QuicSpdyStream(id, session), content_length_(-1) {} | 31 : QuicSpdyStream(id, session), content_length_(-1) {} |
32 | 32 |
33 QuicSimpleServerStream::~QuicSimpleServerStream() {} | 33 QuicSimpleServerStream::~QuicSimpleServerStream() {} |
34 | 34 |
35 void QuicSimpleServerStream::OnInitialHeadersComplete(bool fin, | |
36 size_t frame_len) { | |
37 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len); | |
38 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), | |
39 decompressed_headers().length(), | |
40 &content_length_, &request_headers_)) { | |
41 DVLOG(1) << "Invalid headers"; | |
42 SendErrorResponse(); | |
43 } | |
44 MarkHeadersConsumed(decompressed_headers().length()); | |
45 } | |
46 | |
47 void QuicSimpleServerStream::OnInitialHeadersComplete( | 35 void QuicSimpleServerStream::OnInitialHeadersComplete( |
48 bool fin, | 36 bool fin, |
49 size_t frame_len, | 37 size_t frame_len, |
50 const QuicHeaderList& header_list) { | 38 const QuicHeaderList& header_list) { |
51 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); | 39 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); |
52 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_, | 40 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_, |
53 &request_headers_)) { | 41 &request_headers_)) { |
54 DVLOG(1) << "Invalid headers"; | 42 DVLOG(1) << "Invalid headers"; |
55 SendErrorResponse(); | 43 SendErrorResponse(); |
56 } | 44 } |
57 ConsumeHeaderList(); | 45 ConsumeHeaderList(); |
58 } | 46 } |
59 | 47 |
60 void QuicSimpleServerStream::OnTrailingHeadersComplete(bool fin, | |
61 size_t frame_len) { | |
62 QUIC_BUG << "Server does not support receiving Trailers."; | |
63 SendErrorResponse(); | |
64 } | |
65 | |
66 void QuicSimpleServerStream::OnTrailingHeadersComplete( | 48 void QuicSimpleServerStream::OnTrailingHeadersComplete( |
67 bool fin, | 49 bool fin, |
68 size_t frame_len, | 50 size_t frame_len, |
69 const QuicHeaderList& header_list) { | 51 const QuicHeaderList& header_list) { |
70 QUIC_BUG << "Server does not support receiving Trailers."; | 52 QUIC_BUG << "Server does not support receiving Trailers."; |
71 SendErrorResponse(); | 53 SendErrorResponse(); |
72 } | 54 } |
73 | 55 |
74 void QuicSimpleServerStream::OnDataAvailable() { | 56 void QuicSimpleServerStream::OnDataAvailable() { |
75 while (HasBytesToRead()) { | 57 while (HasBytesToRead()) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 DVLOG(1) << "Writing trailers (fin = true): " | 255 DVLOG(1) << "Writing trailers (fin = true): " |
274 << response_trailers.DebugString(); | 256 << response_trailers.DebugString(); |
275 WriteTrailers(std::move(response_trailers), nullptr); | 257 WriteTrailers(std::move(response_trailers), nullptr); |
276 } | 258 } |
277 | 259 |
278 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 260 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
279 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 261 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
280 "file not found"; | 262 "file not found"; |
281 | 263 |
282 } // namespace net | 264 } // namespace net |
OLD | NEW |