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::HttpRequestInfo request; | 233 net::HttpRequestInfo request; |
234 request.method = FLAGS_body.empty() ? "GET" : "POST"; | 234 request.method = FLAGS_body.empty() ? "GET" : "POST"; |
235 request.url = url; | 235 request.url = url; |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 return 0; | 287 return 0; |
288 } else { | 288 } else { |
289 cout << "Request failed (redirect " << response_code << ")." << endl; | 289 cout << "Request failed (redirect " << response_code << ")." << endl; |
290 return 1; | 290 return 1; |
291 } | 291 } |
292 } else { | 292 } else { |
293 cerr << "Request failed (" << response_code << ")." << endl; | 293 cerr << "Request failed (" << response_code << ")." << endl; |
294 return 1; | 294 return 1; |
295 } | 295 } |
296 } | 296 } |
OLD | NEW |