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 // A binary wrapper for QuicClient. | 5 // A binary wrapper for QuicClient. |
6 // Connects to a host using QUIC, sends a request to the provided URL, and | 6 // Connects to a host using QUIC, sends a request to the provided URL, and |
7 // displays the response. | 7 // displays the response. |
8 // | 8 // |
9 // Some usage examples: | 9 // Some usage examples: |
10 // | 10 // |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 return 1; | 228 return 1; |
229 } | 229 } |
230 cout << "Connected to " << host_port << endl; | 230 cout << "Connected to " << host_port << endl; |
231 | 231 |
232 // Construct a GET or POST request for supplied URL. | 232 // Construct a GET or POST request for supplied URL. |
233 net::BalsaHeaders headers; | 233 net::BalsaHeaders headers; |
234 headers.SetRequestFirstlineFromStringPieces( | 234 headers.SetRequestFirstlineFromStringPieces( |
235 FLAGS_body.empty() ? "GET" : "POST", url.spec(), "HTTP/1.1"); | 235 FLAGS_body.empty() ? "GET" : "POST", url.spec(), "HTTP/1.1"); |
236 | 236 |
237 // Append any additional headers supplied on the command line. | 237 // Append any additional headers supplied on the command line. |
238 vector<string> headers_tokenized; | 238 for (const std::string& header : |
239 Tokenize(FLAGS_headers, ";", &headers_tokenized); | 239 base::SplitString(FLAGS_headers, ";", base::KEEP_WHITESPACE, |
240 for (size_t i = 0; i < headers_tokenized.size(); ++i) { | 240 base::SPLIT_WANT_NONEMPTY)) { |
241 string sp; | 241 string sp; |
242 base::TrimWhitespaceASCII(headers_tokenized[i], base::TRIM_ALL, &sp); | 242 base::TrimWhitespaceASCII(header, base::TRIM_ALL, &sp); |
243 if (sp.empty()) { | 243 if (sp.empty()) { |
244 continue; | 244 continue; |
245 } | 245 } |
246 vector<string> kv; | 246 vector<string> kv; |
247 base::SplitString(sp, ':', &kv); | 247 base::SplitString(sp, ':', &kv); |
248 CHECK_EQ(2u, kv.size()); | 248 CHECK_EQ(2u, kv.size()); |
249 string key; | 249 string key; |
250 base::TrimWhitespaceASCII(kv[0], base::TRIM_ALL, &key); | 250 base::TrimWhitespaceASCII(kv[0], base::TRIM_ALL, &key); |
251 string value; | 251 string value; |
252 base::TrimWhitespaceASCII(kv[1], base::TRIM_ALL, &value); | 252 base::TrimWhitespaceASCII(kv[1], base::TRIM_ALL, &value); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return 0; | 286 return 0; |
287 } else { | 287 } else { |
288 cout << "Request failed (redirect " << response_code << ")." << endl; | 288 cout << "Request failed (redirect " << response_code << ")." << endl; |
289 return 1; | 289 return 1; |
290 } | 290 } |
291 } else { | 291 } else { |
292 cerr << "Request failed (" << response_code << ")." << endl; | 292 cerr << "Request failed (" << response_code << ")." << endl; |
293 return 1; | 293 return 1; |
294 } | 294 } |
295 } | 295 } |
OLD | NEW |