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

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

Issue 2600183002: Clean up quic_simple_client_bin.cc to sync with quic_client_bin.cc (Closed)
Patch Set: Rebase Created 3 years, 11 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
« no previous file with comments | « no previous file | net/tools/quic/quic_simple_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "base/message_loop/message_loop.h" 46 #include "base/message_loop/message_loop.h"
47 #include "net/base/net_errors.h" 47 #include "net/base/net_errors.h"
48 #include "net/base/privacy_mode.h" 48 #include "net/base/privacy_mode.h"
49 #include "net/cert/cert_verifier.h" 49 #include "net/cert/cert_verifier.h"
50 #include "net/cert/multi_log_ct_verifier.h" 50 #include "net/cert/multi_log_ct_verifier.h"
51 #include "net/http/transport_security_state.h" 51 #include "net/http/transport_security_state.h"
52 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" 52 #include "net/quic/chromium/crypto/proof_verifier_chromium.h"
53 #include "net/quic/core/quic_flags.h" 53 #include "net/quic/core/quic_flags.h"
54 #include "net/quic/core/quic_packets.h" 54 #include "net/quic/core/quic_packets.h"
55 #include "net/quic/core/quic_server_id.h" 55 #include "net/quic/core/quic_server_id.h"
56 #include "net/quic/core/quic_utils.h"
57 #include "net/quic/platform/api/quic_socket_address.h" 56 #include "net/quic/platform/api/quic_socket_address.h"
58 #include "net/quic/platform/api/quic_str_cat.h" 57 #include "net/quic/platform/api/quic_str_cat.h"
59 #include "net/quic/platform/api/quic_text_utils.h" 58 #include "net/quic/platform/api/quic_text_utils.h"
60 #include "net/spdy/spdy_header_block.h" 59 #include "net/spdy/spdy_header_block.h"
61 #include "net/tools/epoll_server/epoll_server.h" 60 #include "net/tools/epoll_server/epoll_server.h"
62 #include "net/tools/quic/quic_client.h" 61 #include "net/tools/quic/quic_client.h"
63 #include "net/tools/quic/synchronous_host_resolver.h" 62 #include "net/tools/quic/synchronous_host_resolver.h"
64 #include "url/gurl.h" 63 #include "url/gurl.h"
65 64
66 using base::StringPiece; 65 using base::StringPiece;
67 using net::CertVerifier; 66 using net::CertVerifier;
68 using net::CTPolicyEnforcer; 67 using net::CTPolicyEnforcer;
69 using net::CTVerifier; 68 using net::CTVerifier;
70 using net::MultiLogCTVerifier; 69 using net::MultiLogCTVerifier;
71 using net::ProofVerifier; 70 using net::ProofVerifier;
72 using net::ProofVerifierChromium; 71 using net::ProofVerifierChromium;
72 using net::QuicTextUtils;
73 using net::SpdyHeaderBlock; 73 using net::SpdyHeaderBlock;
74 using net::TransportSecurityState; 74 using net::TransportSecurityState;
75 using net::QuicTextUtils;
76 using std::cout; 75 using std::cout;
77 using std::cerr; 76 using std::cerr;
77 using std::endl;
78 using std::string; 78 using std::string;
79 using std::endl;
80 79
81 // The IP or hostname the quic client will connect to. 80 // The IP or hostname the quic client will connect to.
82 string FLAGS_host = ""; 81 string FLAGS_host = "";
83 // The port to connect to. 82 // The port to connect to.
84 int32_t FLAGS_port = 0; 83 int32_t FLAGS_port = 0;
85 // If set, send a POST with this body. 84 // If set, send a POST with this body.
86 string FLAGS_body = ""; 85 string FLAGS_body = "";
87 // If set, contents are converted from hex to ascii, before sending as body of 86 // If set, contents are converted from hex to ascii, before sending as body of
88 // a POST. e.g. --body_hex=\"68656c6c6f\" 87 // a POST. e.g. --body_hex=\"68656c6c6f\"
89 string FLAGS_body_hex = ""; 88 string FLAGS_body_hex = "";
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 net::PRIVACY_MODE_DISABLED); 252 net::PRIVACY_MODE_DISABLED);
254 net::QuicVersionVector versions = net::AllSupportedVersions(); 253 net::QuicVersionVector versions = net::AllSupportedVersions();
255 if (FLAGS_quic_version != -1) { 254 if (FLAGS_quic_version != -1) {
256 versions.clear(); 255 versions.clear();
257 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); 256 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
258 } 257 }
259 // For secure QUIC we need to verify the cert chain. 258 // For secure QUIC we need to verify the cert chain.
260 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); 259 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault());
261 std::unique_ptr<TransportSecurityState> transport_security_state( 260 std::unique_ptr<TransportSecurityState> transport_security_state(
262 new TransportSecurityState); 261 new TransportSecurityState);
263 transport_security_state.reset(new TransportSecurityState);
264 std::unique_ptr<CTVerifier> ct_verifier(new MultiLogCTVerifier()); 262 std::unique_ptr<CTVerifier> ct_verifier(new MultiLogCTVerifier());
265 std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer(new CTPolicyEnforcer()); 263 std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer(new CTPolicyEnforcer());
266 std::unique_ptr<ProofVerifier> proof_verifier; 264 std::unique_ptr<ProofVerifier> proof_verifier;
267 if (line->HasSwitch("disable-certificate-verification")) { 265 if (line->HasSwitch("disable-certificate-verification")) {
268 proof_verifier.reset(new FakeProofVerifier()); 266 proof_verifier.reset(new FakeProofVerifier());
269 } else { 267 } else {
270 proof_verifier.reset(new ProofVerifierChromium( 268 proof_verifier.reset(new ProofVerifierChromium(
271 cert_verifier.get(), ct_policy_enforcer.get(), 269 cert_verifier.get(), ct_policy_enforcer.get(),
272 transport_security_state.get(), ct_verifier.get())); 270 transport_security_state.get(), ct_verifier.get()));
273 } 271 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 continue; 312 continue;
315 } 313 }
316 std::vector<StringPiece> kv = QuicTextUtils::Split(sp, ':'); 314 std::vector<StringPiece> kv = QuicTextUtils::Split(sp, ':');
317 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]); 315 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]);
318 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]); 316 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]);
319 header_block[kv[0]] = kv[1]; 317 header_block[kv[0]] = kv[1];
320 } 318 }
321 319
322 // Make sure to store the response, for later output. 320 // Make sure to store the response, for later output.
323 client.set_store_response(true); 321 client.set_store_response(true);
322
324 // Send the request. 323 // Send the request.
325 client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true); 324 client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true);
326 325
327 // Print request and response details. 326 // Print request and response details.
328 if (!FLAGS_quiet) { 327 if (!FLAGS_quiet) {
329 cout << "Request:" << endl; 328 cout << "Request:" << endl;
330 cout << "headers:" << header_block.DebugString(); 329 cout << "headers:" << header_block.DebugString();
331 if (!FLAGS_body_hex.empty()) { 330 if (!FLAGS_body_hex.empty()) {
332 // Print the user provided hex, rather than binary body. 331 // Print the user provided hex, rather than binary body.
333 cout << "body:\n" 332 cout << "body:\n"
(...skipping 25 matching lines...) Expand all
359 return 0; 358 return 0;
360 } else { 359 } else {
361 cout << "Request failed (redirect " << response_code << ")." << endl; 360 cout << "Request failed (redirect " << response_code << ")." << endl;
362 return 1; 361 return 1;
363 } 362 }
364 } else { 363 } else {
365 cerr << "Request failed (" << response_code << ")." << endl; 364 cerr << "Request failed (" << response_code << ")." << endl;
366 return 1; 365 return 1;
367 } 366 }
368 } 367 }
OLDNEW
« no previous file with comments | « no previous file | net/tools/quic/quic_simple_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698