| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 if (ContainsKey(*headers, "content-length")) { | 145 if (ContainsKey(*headers, "content-length")) { |
| 146 // Check whether multiple values are consistent. | 146 // Check whether multiple values are consistent. |
| 147 StringPiece content_length_header = (*headers)["content-length"]; | 147 StringPiece content_length_header = (*headers)["content-length"]; |
| 148 vector<string> values = | 148 vector<string> values = |
| 149 base::SplitString(content_length_header, base::StringPiece("\0", 1), | 149 base::SplitString(content_length_header, base::StringPiece("\0", 1), |
| 150 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 150 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 151 for (const string& value : values) { | 151 for (const string& value : values) { |
| 152 int new_value; | 152 int64_t new_value; |
| 153 if (!base::StringToInt(value, &new_value) || new_value < 0) { | 153 if (!base::StringToInt64(value, &new_value) || new_value < 0) { |
| 154 DLOG(ERROR) << "Content length was either unparseable or negative."; | 154 DLOG(ERROR) << "Content length was either unparseable or negative."; |
| 155 return false; | 155 return false; |
| 156 } | 156 } |
| 157 if (*content_length < 0) { | 157 if (*content_length < 0) { |
| 158 *content_length = new_value; | 158 *content_length = new_value; |
| 159 continue; | 159 continue; |
| 160 } | 160 } |
| 161 if (new_value != *content_length) { | 161 if (new_value != *content_length) { |
| 162 DLOG(ERROR) << "Parsed content length " << new_value << " is " | 162 DLOG(ERROR) << "Parsed content length " << new_value << " is " |
| 163 << "inconsistent with previously detected content length " | 163 << "inconsistent with previously detected content length " |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return GURL(GetUrlFromHeaderBlock(headers)).host(); | 248 return GURL(GetUrlFromHeaderBlock(headers)).host(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // static | 251 // static |
| 252 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { | 252 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
| 253 string url(GetUrlFromHeaderBlock(headers)); | 253 string url(GetUrlFromHeaderBlock(headers)); |
| 254 return url != "" && GURL(url).is_valid(); | 254 return url != "" && GURL(url).is_valid(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace net | 257 } // namespace net |
| OLD | NEW |