OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/spdy/spdy_headers_block_parser.h" | 5 #include "net/spdy/spdy_headers_block_parser.h" |
6 | 6 |
7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "net/spdy/spdy_bug_tracker.h" | 8 #include "net/spdy/spdy_bug_tracker.h" |
| 9 #include "net/spdy/spdy_flags.h" |
9 | 10 |
10 namespace net { | 11 namespace net { |
11 namespace { | 12 namespace { |
12 | 13 |
13 // 0 is invalid according to both the SPDY 3.1 and HTTP/2 specifications. | 14 // 0 is invalid according to both the SPDY 3.1 and HTTP/2 specifications. |
14 const SpdyStreamId kInvalidStreamId = 0; | 15 const SpdyStreamId kInvalidStreamId = 0; |
15 | 16 |
16 } // anonymous namespace | 17 } // anonymous namespace |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } else { | 107 } else { |
107 handler_->OnHeader(key, value); | 108 handler_->OnHeader(key, value); |
108 } | 109 } |
109 break; | 110 break; |
110 case FINISHED_HEADER: | 111 case FINISHED_HEADER: |
111 // Prepare for next header or block. | 112 // Prepare for next header or block. |
112 if (--remaining_key_value_pairs_for_frame_ > 0) { | 113 if (--remaining_key_value_pairs_for_frame_ > 0) { |
113 next_state = READING_KEY_LEN; | 114 next_state = READING_KEY_LEN; |
114 } else { | 115 } else { |
115 next_state = READING_HEADER_BLOCK_LEN; | 116 next_state = READING_HEADER_BLOCK_LEN; |
116 handler_->OnHeaderBlockEnd(total_bytes_received_); | 117 if (FLAGS_chromium_http2_flag_log_compressed_size) { |
| 118 // We reach here in two cases: 1) Spdy3 or 2) HTTP/2 without hpack |
| 119 // encoding. For the first case, we just log the uncompressed size |
| 120 // since we are going to deprecate Spdy3 soon. For the second case, |
| 121 // the compressed size is the same as the uncompressed size. |
| 122 handler_->OnHeaderBlockEnd(total_bytes_received_, |
| 123 total_bytes_received_); |
| 124 } else { |
| 125 handler_->OnHeaderBlockEnd(total_bytes_received_); |
| 126 } |
117 stream_id_ = kInvalidStreamId; | 127 stream_id_ = kInvalidStreamId; |
118 // Expect to have consumed all buffer. | 128 // Expect to have consumed all buffer. |
119 if (reader.Available() != 0) { | 129 if (reader.Available() != 0) { |
120 error_ = TOO_MUCH_DATA; | 130 error_ = TOO_MUCH_DATA; |
121 } | 131 } |
122 } | 132 } |
123 break; | 133 break; |
124 } | 134 } |
125 | 135 |
126 if (error_ == NO_PARSER_ERROR) { | 136 if (error_ == NO_PARSER_ERROR) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 size_t SpdyHeadersBlockParser::MaxNumberOfHeaders() { | 188 size_t SpdyHeadersBlockParser::MaxNumberOfHeaders() { |
179 // Account for the length of the header block field. | 189 // Account for the length of the header block field. |
180 size_t max_bytes_for_headers = kMaximumFieldLength - kLengthFieldSize; | 190 size_t max_bytes_for_headers = kMaximumFieldLength - kLengthFieldSize; |
181 | 191 |
182 // A minimal size header is twice the length field size (and has a | 192 // A minimal size header is twice the length field size (and has a |
183 // zero-lengthed key and a zero-lengthed value). | 193 // zero-lengthed key and a zero-lengthed value). |
184 return max_bytes_for_headers / (2 * kLengthFieldSize); | 194 return max_bytes_for_headers / (2 * kLengthFieldSize); |
185 } | 195 } |
186 | 196 |
187 } // namespace net | 197 } // namespace net |
OLD | NEW |