| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "net/base/ip_endpoint.h" | 49 #include "net/base/ip_endpoint.h" |
| 50 #include "net/base/net_errors.h" | 50 #include "net/base/net_errors.h" |
| 51 #include "net/base/privacy_mode.h" | 51 #include "net/base/privacy_mode.h" |
| 52 #include "net/cert/cert_verifier.h" | 52 #include "net/cert/cert_verifier.h" |
| 53 #include "net/http/transport_security_state.h" | 53 #include "net/http/transport_security_state.h" |
| 54 #include "net/log/net_log.h" | 54 #include "net/log/net_log.h" |
| 55 #include "net/quic/crypto/proof_verifier_chromium.h" | 55 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 56 #include "net/quic/quic_protocol.h" | 56 #include "net/quic/quic_protocol.h" |
| 57 #include "net/quic/quic_server_id.h" | 57 #include "net/quic/quic_server_id.h" |
| 58 #include "net/quic/quic_utils.h" | 58 #include "net/quic/quic_utils.h" |
| 59 #include "net/spdy/spdy_header_block.h" |
| 59 #include "net/tools/epoll_server/epoll_server.h" | 60 #include "net/tools/epoll_server/epoll_server.h" |
| 60 #include "net/tools/quic/quic_client.h" | 61 #include "net/tools/quic/quic_client.h" |
| 61 #include "net/tools/quic/spdy_balsa_utils.h" | 62 #include "net/tools/quic/spdy_balsa_utils.h" |
| 62 #include "net/tools/quic/synchronous_host_resolver.h" | 63 #include "net/tools/quic/synchronous_host_resolver.h" |
| 63 #include "url/gurl.h" | 64 #include "url/gurl.h" |
| 64 | 65 |
| 65 using base::StringPiece; | 66 using base::StringPiece; |
| 66 using net::CertVerifier; | 67 using net::CertVerifier; |
| 67 using net::ProofVerifierChromium; | 68 using net::ProofVerifierChromium; |
| 68 using net::TransportSecurityState; | 69 using net::TransportSecurityState; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Send the request. | 269 // Send the request. |
| 269 net::SpdyHeaderBlock header_block = | 270 net::SpdyHeaderBlock header_block = |
| 270 net::tools::SpdyBalsaUtils::RequestHeadersToSpdyHeaders( | 271 net::tools::SpdyBalsaUtils::RequestHeadersToSpdyHeaders( |
| 271 headers, client.session()->connection()->version()); | 272 headers, client.session()->connection()->version()); |
| 272 client.SendRequestAndWaitForResponse(headers, FLAGS_body, /*fin=*/true); | 273 client.SendRequestAndWaitForResponse(headers, FLAGS_body, /*fin=*/true); |
| 273 | 274 |
| 274 // Print request and response details. | 275 // Print request and response details. |
| 275 if (!FLAGS_quiet) { | 276 if (!FLAGS_quiet) { |
| 276 cout << "Request:" << endl; | 277 cout << "Request:" << endl; |
| 277 cout << "headers:" << endl; | 278 cout << "headers:" << endl; |
| 278 for (const std::pair<string, string>& kv : header_block) { | 279 for (const auto& kv : header_block) { |
| 279 cout << " " << kv.first << ": " << kv.second << endl; | 280 cout << " " << kv.first << ": " << kv.second << endl; |
| 280 } | 281 } |
| 281 cout << "body: " << FLAGS_body << endl; | 282 cout << "body: " << FLAGS_body << endl; |
| 282 cout << endl; | 283 cout << endl; |
| 283 cout << "Response:" << endl; | 284 cout << "Response:" << endl; |
| 284 cout << "headers: " << client.latest_response_headers() << endl; | 285 cout << "headers: " << client.latest_response_headers() << endl; |
| 285 cout << "body: " << client.latest_response_body() << endl; | 286 cout << "body: " << client.latest_response_body() << endl; |
| 286 } | 287 } |
| 287 | 288 |
| 288 size_t response_code = client.latest_response_code(); | 289 size_t response_code = client.latest_response_code(); |
| 289 if (response_code >= 200 && response_code < 300) { | 290 if (response_code >= 200 && response_code < 300) { |
| 290 cout << "Request succeeded (" << response_code << ")." << endl; | 291 cout << "Request succeeded (" << response_code << ")." << endl; |
| 291 return 0; | 292 return 0; |
| 292 } else if (response_code >= 300 && response_code < 400) { | 293 } else if (response_code >= 300 && response_code < 400) { |
| 293 if (FLAGS_redirect_is_success) { | 294 if (FLAGS_redirect_is_success) { |
| 294 cout << "Request succeeded (redirect " << response_code << ")." << endl; | 295 cout << "Request succeeded (redirect " << response_code << ")." << endl; |
| 295 return 0; | 296 return 0; |
| 296 } else { | 297 } else { |
| 297 cout << "Request failed (redirect " << response_code << ")." << endl; | 298 cout << "Request failed (redirect " << response_code << ")." << endl; |
| 298 return 1; | 299 return 1; |
| 299 } | 300 } |
| 300 } else { | 301 } else { |
| 301 cerr << "Request failed (" << response_code << ")." << endl; | 302 cerr << "Request failed (" << response_code << ")." << endl; |
| 302 return 1; | 303 return 1; |
| 303 } | 304 } |
| 304 } | 305 } |
| OLD | NEW |