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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 if (line->HasSwitch("redirect_is_success")) { | 159 if (line->HasSwitch("redirect_is_success")) { |
160 FLAGS_redirect_is_success = true; | 160 FLAGS_redirect_is_success = true; |
161 } | 161 } |
162 if (line->HasSwitch("initial_mtu")) { | 162 if (line->HasSwitch("initial_mtu")) { |
163 if (!base::StringToInt(line->GetSwitchValueASCII("initial_mtu"), | 163 if (!base::StringToInt(line->GetSwitchValueASCII("initial_mtu"), |
164 &FLAGS_initial_mtu)) { | 164 &FLAGS_initial_mtu)) { |
165 std::cerr << "--initial_mtu must be an integer\n"; | 165 std::cerr << "--initial_mtu must be an integer\n"; |
166 return 1; | 166 return 1; |
167 } | 167 } |
168 } else { | |
169 // Default and initial maximum size in bytes of a QUIC packet, which is used | |
170 // to set connection's max_packet_length. | |
171 FLAGS_initial_mtu = net::kDefaultMaxPacketSize; | |
172 } | 168 } |
173 | 169 |
174 VLOG(1) << "server host: " << FLAGS_host << " port: " << FLAGS_port | 170 VLOG(1) << "server host: " << FLAGS_host << " port: " << FLAGS_port |
175 << " body: " << FLAGS_body << " headers: " << FLAGS_headers | 171 << " body: " << FLAGS_body << " headers: " << FLAGS_headers |
176 << " quiet: " << FLAGS_quiet | 172 << " quiet: " << FLAGS_quiet |
177 << " quic-version: " << FLAGS_quic_version | 173 << " quic-version: " << FLAGS_quic_version |
178 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok | 174 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok |
179 << " redirect_is_success: " << FLAGS_redirect_is_success | 175 << " redirect_is_success: " << FLAGS_redirect_is_success |
180 << " initial_mtu: " << FLAGS_initial_mtu; | 176 << " initial_mtu: " << FLAGS_initial_mtu; |
181 | 177 |
(...skipping 30 matching lines...) Expand all Loading... |
212 net::PRIVACY_MODE_DISABLED); | 208 net::PRIVACY_MODE_DISABLED); |
213 net::QuicVersionVector versions = net::QuicSupportedVersions(); | 209 net::QuicVersionVector versions = net::QuicSupportedVersions(); |
214 if (FLAGS_quic_version != -1) { | 210 if (FLAGS_quic_version != -1) { |
215 versions.clear(); | 211 versions.clear(); |
216 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); | 212 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); |
217 } | 213 } |
218 net::tools::QuicSimpleClient client(net::IPEndPoint(ip_addr, FLAGS_port), | 214 net::tools::QuicSimpleClient client(net::IPEndPoint(ip_addr, FLAGS_port), |
219 server_id, versions); | 215 server_id, versions); |
220 scoped_ptr<CertVerifier> cert_verifier; | 216 scoped_ptr<CertVerifier> cert_verifier; |
221 scoped_ptr<TransportSecurityState> transport_security_state; | 217 scoped_ptr<TransportSecurityState> transport_security_state; |
222 if (FLAGS_initial_mtu != 0) { | 218 client.set_initial_max_packet_length( |
223 client.set_initial_max_packet_length(FLAGS_initial_mtu); | 219 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); |
224 } | |
225 if (is_https) { | 220 if (is_https) { |
226 // For secure QUIC we need to verify the cert chain.a | 221 // For secure QUIC we need to verify the cert chain.a |
227 cert_verifier.reset(CertVerifier::CreateDefault()); | 222 cert_verifier.reset(CertVerifier::CreateDefault()); |
228 transport_security_state.reset(new TransportSecurityState); | 223 transport_security_state.reset(new TransportSecurityState); |
229 client.SetProofVerifier(new ProofVerifierChromium( | 224 client.SetProofVerifier(new ProofVerifierChromium( |
230 cert_verifier.get(), transport_security_state.get())); | 225 cert_verifier.get(), transport_security_state.get())); |
231 } | 226 } |
232 if (!client.Initialize()) { | 227 if (!client.Initialize()) { |
233 cerr << "Failed to initialize client." << endl; | 228 cerr << "Failed to initialize client." << endl; |
234 return 1; | 229 return 1; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 return 0; | 300 return 0; |
306 } else { | 301 } else { |
307 cout << "Request failed (redirect " << response_code << ")." << endl; | 302 cout << "Request failed (redirect " << response_code << ")." << endl; |
308 return 1; | 303 return 1; |
309 } | 304 } |
310 } else { | 305 } else { |
311 cerr << "Request failed (" << response_code << ")." << endl; | 306 cerr << "Request failed (" << response_code << ")." << endl; |
312 return 1; | 307 return 1; |
313 } | 308 } |
314 } | 309 } |
OLD | NEW |