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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 client.SendRequestAndWaitForResponse(headers, FLAGS_body, /*fin=*/true); | 262 client.SendRequestAndWaitForResponse(headers, FLAGS_body, /*fin=*/true); |
263 | 263 |
264 // Print request and response details. | 264 // Print request and response details. |
265 if (!FLAGS_quiet) { | 265 if (!FLAGS_quiet) { |
266 cout << "Request:" << endl; | 266 cout << "Request:" << endl; |
267 cout << "headers:" << endl; | 267 cout << "headers:" << endl; |
268 for (const std::pair<string, string>& kv : header_block) { | 268 for (const std::pair<string, string>& kv : header_block) { |
269 cout << " " << kv.first << ": " << kv.second << endl; | 269 cout << " " << kv.first << ": " << kv.second << endl; |
270 } | 270 } |
271 cout << "body: " << FLAGS_body << endl; | 271 cout << "body: " << FLAGS_body << endl; |
272 cout << endl << "Response:"; | 272 cout << endl; |
| 273 cout << "Response:" << endl; |
273 cout << "headers: " << client.latest_response_headers() << endl; | 274 cout << "headers: " << client.latest_response_headers() << endl; |
274 cout << "body: " << client.latest_response_body() << endl; | 275 cout << "body: " << client.latest_response_body() << endl; |
275 } | 276 } |
276 | 277 |
277 size_t response_code = client.latest_response_code(); | 278 size_t response_code = client.latest_response_code(); |
278 if (response_code >= 200 && response_code < 300) { | 279 if (response_code >= 200 && response_code < 300) { |
279 cout << "Request succeeded (" << response_code << ")." << endl; | 280 cout << "Request succeeded (" << response_code << ")." << endl; |
280 return 0; | 281 return 0; |
281 } else if (response_code >= 300 && response_code < 400) { | 282 } else if (response_code >= 300 && response_code < 400) { |
282 if (FLAGS_redirect_is_success) { | 283 if (FLAGS_redirect_is_success) { |
283 cout << "Request succeeded (redirect " << response_code << ")." << endl; | 284 cout << "Request succeeded (redirect " << response_code << ")." << endl; |
284 return 0; | 285 return 0; |
285 } else { | 286 } else { |
286 cout << "Request failed (redirect " << response_code << ")." << endl; | 287 cout << "Request failed (redirect " << response_code << ")." << endl; |
287 return 1; | 288 return 1; |
288 } | 289 } |
289 } else { | 290 } else { |
290 cerr << "Request failed (" << response_code << ")." << endl; | 291 cerr << "Request failed (" << response_code << ")." << endl; |
291 return 1; | 292 return 1; |
292 } | 293 } |
293 } | 294 } |
OLD | NEW |