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/core/spdy_utils.h" | 5 #include "net/quic/core/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 // static | 58 // static |
59 bool SpdyUtils::ExtractContentLengthFromHeaders(int64_t* content_length, | 59 bool SpdyUtils::ExtractContentLengthFromHeaders(int64_t* content_length, |
60 SpdyHeaderBlock* headers) { | 60 SpdyHeaderBlock* headers) { |
61 auto it = headers->find("content-length"); | 61 auto it = headers->find("content-length"); |
62 if (it == headers->end()) { | 62 if (it == headers->end()) { |
63 return false; | 63 return false; |
64 } else { | 64 } else { |
65 // Check whether multiple values are consistent. | 65 // Check whether multiple values are consistent. |
66 base::StringPiece content_length_header = it->second; | 66 StringPiece content_length_header = it->second; |
67 vector<string> values = | 67 std::vector<string> values = |
68 base::SplitString(content_length_header, base::StringPiece("\0", 1), | 68 base::SplitString(content_length_header, base::StringPiece("\0", 1), |
69 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 69 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
70 for (const string& value : values) { | 70 for (const string& value : values) { |
71 int64_t new_value; | 71 int64_t new_value; |
72 if (!base::StringToInt64(value, &new_value) || new_value < 0) { | 72 if (!base::StringToInt64(value, &new_value) || new_value < 0) { |
73 DLOG(ERROR) << "Content length was either unparseable or negative."; | 73 DLOG(ERROR) << "Content length was either unparseable or negative."; |
74 return false; | 74 return false; |
75 } | 75 } |
76 if (*content_length < 0) { | 76 if (*content_length < 0) { |
77 *content_length = new_value; | 77 *content_length = new_value; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 pos = url.find("/", start); | 252 pos = url.find("/", start); |
253 if (pos == string::npos) { | 253 if (pos == string::npos) { |
254 return false; | 254 return false; |
255 } | 255 } |
256 (*headers)[":authority"] = url.substr(start, pos - start); | 256 (*headers)[":authority"] = url.substr(start, pos - start); |
257 (*headers)[":path"] = url.substr(pos); | 257 (*headers)[":path"] = url.substr(pos); |
258 return true; | 258 return true; |
259 } | 259 } |
260 | 260 |
261 } // namespace net | 261 } // namespace net |
OLD | NEW |