| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 // Append any additional headers supplied on the command line. | 236 // Append any additional headers supplied on the command line. |
| 237 vector<string> headers_tokenized; | 237 vector<string> headers_tokenized; |
| 238 Tokenize(FLAGS_headers, ";", &headers_tokenized); | 238 Tokenize(FLAGS_headers, ";", &headers_tokenized); |
| 239 for (size_t i = 0; i < headers_tokenized.size(); ++i) { | 239 for (size_t i = 0; i < headers_tokenized.size(); ++i) { |
| 240 string sp; | 240 string sp; |
| 241 base::TrimWhitespaceASCII(headers_tokenized[i], base::TRIM_ALL, &sp); | 241 base::TrimWhitespaceASCII(headers_tokenized[i], base::TRIM_ALL, &sp); |
| 242 if (sp.empty()) { | 242 if (sp.empty()) { |
| 243 continue; | 243 continue; |
| 244 } | 244 } |
| 245 vector<string> kv; | 245 vector<string> kv = |
| 246 base::SplitString(sp, ':', &kv); | 246 base::SplitString(sp, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 247 CHECK_EQ(2u, kv.size()); | 247 CHECK_EQ(2u, kv.size()); |
| 248 string key; | 248 string key; |
| 249 base::TrimWhitespaceASCII(kv[0], base::TRIM_ALL, &key); | 249 base::TrimWhitespaceASCII(kv[0], base::TRIM_ALL, &key); |
| 250 string value; | 250 string value; |
| 251 base::TrimWhitespaceASCII(kv[1], base::TRIM_ALL, &value); | 251 base::TrimWhitespaceASCII(kv[1], base::TRIM_ALL, &value); |
| 252 request.extra_headers.SetHeader(key, value); | 252 request.extra_headers.SetHeader(key, value); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Make sure to store the response, for later output. | 255 // Make sure to store the response, for later output. |
| 256 client.set_store_response(true); | 256 client.set_store_response(true); |
| (...skipping 29 matching lines...) Expand all 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 |