Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: net/tools/quic/quic_simple_client_bin.cc

Issue 2130103002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 net::HTTP2, /*direct=*/true, 319 net::HTTP2, /*direct=*/true,
320 &header_block); 320 &header_block);
321 client.SendRequestAndWaitForResponse(request, body, /*fin=*/true); 321 client.SendRequestAndWaitForResponse(request, body, /*fin=*/true);
322 322
323 // Print request and response details. 323 // Print request and response details.
324 if (!FLAGS_quiet) { 324 if (!FLAGS_quiet) {
325 cout << "Request:" << endl; 325 cout << "Request:" << endl;
326 cout << "headers:" << header_block.DebugString(); 326 cout << "headers:" << header_block.DebugString();
327 if (!FLAGS_body_hex.empty()) { 327 if (!FLAGS_body_hex.empty()) {
328 // Print the user provided hex, rather than binary body. 328 // Print the user provided hex, rather than binary body.
329 cout << "body hex: " << FLAGS_body_hex << endl; 329 cout << "body:\n"
330 cout << "body ascii: " << net::QuicUtils::BinaryToAscii( 330 << net::QuicUtils::HexDump(net::QuicUtils::HexDecode(FLAGS_body_hex))
331 net::QuicUtils::HexDecode(FLAGS_body_hex))
332 << endl; 331 << endl;
333 } else { 332 } else {
334 cout << "body: " << body << endl; 333 cout << "body: " << body << endl;
335 } 334 }
336 cout << endl; 335 cout << endl;
337 cout << "Response:" << endl; 336 cout << "Response:" << endl;
338 cout << "headers: " << client.latest_response_headers() << endl; 337 cout << "headers: " << client.latest_response_headers() << endl;
339 string response_body = client.latest_response_body(); 338 string response_body = client.latest_response_body();
340 if (!FLAGS_body_hex.empty()) { 339 if (!FLAGS_body_hex.empty()) {
341 // Assume response is binary data. 340 // Assume response is binary data.
342 cout << "body hex: " << net::QuicUtils::HexEncode(response_body) 341 cout << "body:\n" << net::QuicUtils::HexDump(response_body) << endl;
343 << endl;
344 cout << "body ascii: " << net::QuicUtils::BinaryToAscii(response_body)
345 << endl;
346 } else { 342 } else {
347 cout << "body: " << response_body << endl; 343 cout << "body: " << response_body << endl;
348 } 344 }
349 } 345 }
350 346
351 size_t response_code = client.latest_response_code(); 347 size_t response_code = client.latest_response_code();
352 if (response_code >= 200 && response_code < 300) { 348 if (response_code >= 200 && response_code < 300) {
353 cout << "Request succeeded (" << response_code << ")." << endl; 349 cout << "Request succeeded (" << response_code << ")." << endl;
354 return 0; 350 return 0;
355 } else if (response_code >= 300 && response_code < 400) { 351 } else if (response_code >= 300 && response_code < 400) {
356 if (FLAGS_redirect_is_success) { 352 if (FLAGS_redirect_is_success) {
357 cout << "Request succeeded (redirect " << response_code << ")." << endl; 353 cout << "Request succeeded (redirect " << response_code << ")." << endl;
358 return 0; 354 return 0;
359 } else { 355 } else {
360 cout << "Request failed (redirect " << response_code << ")." << endl; 356 cout << "Request failed (redirect " << response_code << ")." << endl;
361 return 1; 357 return 1;
362 } 358 }
363 } else { 359 } else {
364 cerr << "Request failed (" << response_code << ")." << endl; 360 cerr << "Request failed (" << response_code << ")." << endl;
365 return 1; 361 return 1;
366 } 362 }
367 } 363 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_epoll_connection_helper_test.cc ('k') | net/tools/quic/quic_simple_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698