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

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

Issue 1025133002: Revert of Make the simple QUIC client able to resolve hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « net/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/synchronous_host_resolver.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 29 matching lines...) Expand all
40 40
41 #include <iostream> 41 #include <iostream>
42 42
43 #include "base/at_exit.h" 43 #include "base/at_exit.h"
44 #include "base/command_line.h" 44 #include "base/command_line.h"
45 #include "base/logging.h" 45 #include "base/logging.h"
46 #include "base/strings/string_number_conversions.h" 46 #include "base/strings/string_number_conversions.h"
47 #include "base/strings/string_split.h" 47 #include "base/strings/string_split.h"
48 #include "base/strings/string_util.h" 48 #include "base/strings/string_util.h"
49 #include "net/base/ip_endpoint.h" 49 #include "net/base/ip_endpoint.h"
50 #include "net/base/net_errors.h"
51 #include "net/base/net_log.h"
52 #include "net/base/privacy_mode.h" 50 #include "net/base/privacy_mode.h"
53 #include "net/cert/cert_verifier.h" 51 #include "net/cert/cert_verifier.h"
54 #include "net/http/http_request_info.h" 52 #include "net/http/http_request_info.h"
55 #include "net/http/transport_security_state.h" 53 #include "net/http/transport_security_state.h"
56 #include "net/quic/crypto/proof_verifier_chromium.h" 54 #include "net/quic/crypto/proof_verifier_chromium.h"
57 #include "net/quic/quic_protocol.h" 55 #include "net/quic/quic_protocol.h"
58 #include "net/quic/quic_server_id.h" 56 #include "net/quic/quic_server_id.h"
59 #include "net/quic/quic_utils.h" 57 #include "net/quic/quic_utils.h"
60 #include "net/spdy/spdy_http_utils.h" 58 #include "net/spdy/spdy_http_utils.h"
61 #include "net/tools/quic/quic_simple_client.h" 59 #include "net/tools/quic/quic_simple_client.h"
62 #include "net/tools/quic/synchronous_host_resolver.h"
63 #include "url/gurl.h" 60 #include "url/gurl.h"
64 61
65 using base::StringPiece; 62 using base::StringPiece;
66 using net::CertVerifier; 63 using net::CertVerifier;
67 using net::ProofVerifierChromium; 64 using net::ProofVerifierChromium;
68 using net::TransportSecurityState; 65 using net::TransportSecurityState;
69 using std::cout; 66 using std::cout;
70 using std::cerr; 67 using std::cerr;
71 using std::map; 68 using std::map;
72 using std::string; 69 using std::string;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 base::AtExitManager exit_manager; 163 base::AtExitManager exit_manager;
167 base::MessageLoopForIO message_loop; 164 base::MessageLoopForIO message_loop;
168 165
169 // Determine IP address to connect to from supplied hostname. 166 // Determine IP address to connect to from supplied hostname.
170 net::IPAddressNumber ip_addr; 167 net::IPAddressNumber ip_addr;
171 168
172 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus 169 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus
173 // protocol is required in the URL. 170 // protocol is required in the URL.
174 GURL url(urls[0]); 171 GURL url(urls[0]);
175 string host = FLAGS_host; 172 string host = FLAGS_host;
173 // TODO(rtenneti): get ip_addr from hostname by doing host resolution.
176 if (host.empty()) { 174 if (host.empty()) {
177 host = url.host(); 175 LOG(ERROR) << "--host must be specified\n";
176 return 1;
178 } 177 }
179 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) { 178 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
180 net::AddressList addresses; 179 LOG(ERROR) << "--host could not be parsed as an IP address\n";
181 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses); 180 return 1;
182 if (rv != net::OK) {
183 LOG(ERROR) << "Unable to resolve '" << host << "' : "
184 << net::ErrorToString(rv);
185 return 1;
186 }
187 ip_addr = addresses[0].address();
188 } 181 }
189 182
190 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port); 183 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
191 VLOG(1) << "Resolved " << host << " to " << host_port << endl; 184 VLOG(1) << "Resolved " << host << " to " << host_port << endl;
192 185
193 // Build the client, and try to connect. 186 // Build the client, and try to connect.
194 bool is_https = (FLAGS_port == 443); 187 bool is_https = (FLAGS_port == 443);
195 net::QuicServerId server_id(host, FLAGS_port, is_https, 188 net::QuicServerId server_id(host, FLAGS_port, is_https,
196 net::PRIVACY_MODE_DISABLED); 189 net::PRIVACY_MODE_DISABLED);
197 net::QuicVersionVector versions = net::QuicSupportedVersions(); 190 net::QuicVersionVector versions = net::QuicSupportedVersions();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return 0; 280 return 0;
288 } else { 281 } else {
289 cout << "Request failed (redirect " << response_code << ")." << endl; 282 cout << "Request failed (redirect " << response_code << ")." << endl;
290 return 1; 283 return 1;
291 } 284 }
292 } else { 285 } else {
293 cerr << "Request failed (" << response_code << ")." << endl; 286 cerr << "Request failed (" << response_code << ")." << endl;
294 return 1; 287 return 1;
295 } 288 }
296 } 289 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/synchronous_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698