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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 | 328 |
329 // Send the request. | 329 // Send the request. |
330 net::SpdyHeaderBlock header_block = | 330 net::SpdyHeaderBlock header_block = |
331 net::tools::SpdyBalsaUtils::RequestHeadersToSpdyHeaders(headers); | 331 net::tools::SpdyBalsaUtils::RequestHeadersToSpdyHeaders(headers); |
332 client.SendRequestAndWaitForResponse(headers, body, /*fin=*/true); | 332 client.SendRequestAndWaitForResponse(headers, body, /*fin=*/true); |
333 | 333 |
334 // Print request and response details. | 334 // Print request and response details. |
335 if (!FLAGS_quiet) { | 335 if (!FLAGS_quiet) { |
336 cout << "Request:" << endl; | 336 cout << "Request:" << endl; |
337 cout << "headers:" << header_block.DebugString(); | 337 cout << "headers:" << header_block.DebugString(); |
338 cout << "body: " << body << endl; | 338 string body_to_print = body; |
339 if (!FLAGS_body_hex.empty()) { | |
340 // Print the user provided hex, rather than binary body. | |
341 body_to_print = StrCat("(hex) 0x", FLAGS_body_hex); | |
Ryan Hamilton
2015/12/21 17:39:29
Does this compile? I don't think we have StrCat in
| |
342 } | |
343 cout << "body: " << body_to_print << endl; | |
339 cout << endl; | 344 cout << endl; |
340 cout << "Response:" << endl; | 345 cout << "Response:" << endl; |
341 cout << "headers: " << client.latest_response_headers() << endl; | 346 cout << "headers: " << client.latest_response_headers() << endl; |
342 cout << "body: " << client.latest_response_body() << endl; | 347 cout << "body: " << client.latest_response_body() << endl; |
343 cout << "trailers: " << client.latest_response_trailers() << endl; | 348 cout << "trailers: " << client.latest_response_trailers() << endl; |
344 } | 349 } |
345 | 350 |
346 size_t response_code = client.latest_response_code(); | 351 size_t response_code = client.latest_response_code(); |
347 if (response_code >= 200 && response_code < 300) { | 352 if (response_code >= 200 && response_code < 300) { |
348 cout << "Request succeeded (" << response_code << ")." << endl; | 353 cout << "Request succeeded (" << response_code << ")." << endl; |
349 return 0; | 354 return 0; |
350 } else if (response_code >= 300 && response_code < 400) { | 355 } else if (response_code >= 300 && response_code < 400) { |
351 if (FLAGS_redirect_is_success) { | 356 if (FLAGS_redirect_is_success) { |
352 cout << "Request succeeded (redirect " << response_code << ")." << endl; | 357 cout << "Request succeeded (redirect " << response_code << ")." << endl; |
353 return 0; | 358 return 0; |
354 } else { | 359 } else { |
355 cout << "Request failed (redirect " << response_code << ")." << endl; | 360 cout << "Request failed (redirect " << response_code << ")." << endl; |
356 return 1; | 361 return 1; |
357 } | 362 } |
358 } else { | 363 } else { |
359 cerr << "Request failed (" << response_code << ")." << endl; | 364 cerr << "Request failed (" << response_code << ")." << endl; |
360 return 1; | 365 return 1; |
361 } | 366 } |
362 } | 367 } |
OLD | NEW |