| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/quic/spdy_utils.h" | 5 #include "net/quic/spdy_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 if (ContainsKey(*headers, "content-length")) { | 141 if (ContainsKey(*headers, "content-length")) { |
| 142 // Check whether multiple values are consistent. | 142 // Check whether multiple values are consistent. |
| 143 StringPiece content_length_header = (*headers)["content-length"]; | 143 StringPiece content_length_header = (*headers)["content-length"]; |
| 144 vector<string> values = | 144 vector<string> values = |
| 145 base::SplitString(content_length_header, base::StringPiece("\0", 1), | 145 base::SplitString(content_length_header, base::StringPiece("\0", 1), |
| 146 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 146 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 147 for (const string& value : values) { | 147 for (const string& value : values) { |
| 148 int new_value; | 148 int64_t new_value; |
| 149 if (!base::StringToInt(value, &new_value) || new_value < 0) { | 149 if (!base::StringToInt64(value, &new_value) || new_value < 0) { |
| 150 DLOG(ERROR) << "Content length was either unparseable or negative."; | 150 DLOG(ERROR) << "Content length was either unparseable or negative."; |
| 151 return false; | 151 return false; |
| 152 } | 152 } |
| 153 if (*content_length < 0) { | 153 if (*content_length < 0) { |
| 154 *content_length = new_value; | 154 *content_length = new_value; |
| 155 continue; | 155 continue; |
| 156 } | 156 } |
| 157 if (new_value != *content_length) { | 157 if (new_value != *content_length) { |
| 158 DLOG(ERROR) << "Parsed content length " << new_value << " is " | 158 DLOG(ERROR) << "Parsed content length " << new_value << " is " |
| 159 << "inconsistent with previously detected content length " | 159 << "inconsistent with previously detected content length " |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 return GURL(GetUrlFromHeaderBlock(headers)).host(); | 244 return GURL(GetUrlFromHeaderBlock(headers)).host(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // static | 247 // static |
| 248 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { | 248 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
| 249 string url(GetUrlFromHeaderBlock(headers)); | 249 string url(GetUrlFromHeaderBlock(headers)); |
| 250 return url != "" && GURL(url).is_valid(); | 250 return url != "" && GURL(url).is_valid(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace net | 253 } // namespace net |
| OLD | NEW |