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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 using std::cout; | 74 using std::cout; |
75 using std::cerr; | 75 using std::cerr; |
76 using std::map; | 76 using std::map; |
77 using std::string; | 77 using std::string; |
78 using std::vector; | 78 using std::vector; |
79 using std::endl; | 79 using std::endl; |
80 | 80 |
81 // The IP or hostname the quic client will connect to. | 81 // The IP or hostname the quic client will connect to. |
82 string FLAGS_host = ""; | 82 string FLAGS_host = ""; |
83 // The port to connect to. | 83 // The port to connect to. |
84 int32 FLAGS_port = 0; | 84 int32_t FLAGS_port = 0; |
85 // If set, send a POST with this body. | 85 // If set, send a POST with this body. |
86 string FLAGS_body = ""; | 86 string FLAGS_body = ""; |
87 // If set, contents are converted from hex to ascii, before sending as body of | 87 // If set, contents are converted from hex to ascii, before sending as body of |
88 // a POST. e.g. --body_hex=\"68656c6c6f\" | 88 // a POST. e.g. --body_hex=\"68656c6c6f\" |
89 string FLAGS_body_hex = ""; | 89 string FLAGS_body_hex = ""; |
90 // A semicolon separated list of key:value pairs to add to request headers. | 90 // A semicolon separated list of key:value pairs to add to request headers. |
91 string FLAGS_headers = ""; | 91 string FLAGS_headers = ""; |
92 // Set to true for a quieter output experience. | 92 // Set to true for a quieter output experience. |
93 bool FLAGS_quiet = false; | 93 bool FLAGS_quiet = false; |
94 // QUIC version to speak, e.g. 21. If not set, then all available versions are | 94 // QUIC version to speak, e.g. 21. If not set, then all available versions are |
95 // offered in the handshake. | 95 // offered in the handshake. |
96 int32 FLAGS_quic_version = -1; | 96 int32_t FLAGS_quic_version = -1; |
97 // If true, a version mismatch in the handshake is not considered a failure. | 97 // If true, a version mismatch in the handshake is not considered a failure. |
98 // Useful for probing a server to determine if it speaks any version of QUIC. | 98 // Useful for probing a server to determine if it speaks any version of QUIC. |
99 bool FLAGS_version_mismatch_ok = false; | 99 bool FLAGS_version_mismatch_ok = false; |
100 // If true, an HTTP response code of 3xx is considered to be a successful | 100 // If true, an HTTP response code of 3xx is considered to be a successful |
101 // response, otherwise a failure. | 101 // response, otherwise a failure. |
102 bool FLAGS_redirect_is_success = true; | 102 bool FLAGS_redirect_is_success = true; |
103 // Initial MTU of the connection. | 103 // Initial MTU of the connection. |
104 int32 FLAGS_initial_mtu = 0; | 104 int32_t FLAGS_initial_mtu = 0; |
105 | 105 |
106 class FakeCertVerifier : public net::CertVerifier { | 106 class FakeCertVerifier : public net::CertVerifier { |
107 public: | 107 public: |
108 int Verify(net::X509Certificate* cert, | 108 int Verify(net::X509Certificate* cert, |
109 const std::string& hostname, | 109 const std::string& hostname, |
110 const std::string& ocsp_response, | 110 const std::string& ocsp_response, |
111 int flags, | 111 int flags, |
112 net::CRLSet* crl_set, | 112 net::CRLSet* crl_set, |
113 net::CertVerifyResult* verify_result, | 113 net::CertVerifyResult* verify_result, |
114 const net::CompletionCallback& callback, | 114 const net::CompletionCallback& callback, |
115 scoped_ptr<net::CertVerifier::Request>* out_req, | 115 scoped_ptr<net::CertVerifier::Request>* out_req, |
116 const net::BoundNetLog& net_log) override { | 116 const net::BoundNetLog& net_log) override { |
117 return net::OK; | 117 return net::OK; |
118 } | 118 } |
119 | 119 |
120 // Returns true if this CertVerifier supports stapled OCSP responses. | 120 // Returns true if this CertVerifier supports stapled OCSP responses. |
121 bool SupportsOCSPStapling() override { return false; } | 121 bool SupportsOCSPStapling() override { return false; } |
122 }; | 122 }; |
123 | 123 |
124 static bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) { | 124 static bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) { |
125 bytes->clear(); | 125 bytes->clear(); |
126 if (hex.empty()) | 126 if (hex.empty()) |
127 return true; | 127 return true; |
128 std::vector<uint8> v; | 128 std::vector<uint8_t> v; |
129 if (!base::HexStringToBytes(hex.as_string(), &v)) | 129 if (!base::HexStringToBytes(hex.as_string(), &v)) |
130 return false; | 130 return false; |
131 if (!v.empty()) | 131 if (!v.empty()) |
132 bytes->assign(reinterpret_cast<const char*>(&v[0]), v.size()); | 132 bytes->assign(reinterpret_cast<const char*>(&v[0]), v.size()); |
133 return true; | 133 return true; |
134 }; | 134 }; |
135 | 135 |
136 int main(int argc, char* argv[]) { | 136 int main(int argc, char* argv[]) { |
137 base::CommandLine::Init(argc, argv); | 137 base::CommandLine::Init(argc, argv); |
138 base::CommandLine* line = base::CommandLine::ForCurrentProcess(); | 138 base::CommandLine* line = base::CommandLine::ForCurrentProcess(); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 return 0; | 354 return 0; |
355 } else { | 355 } else { |
356 cout << "Request failed (redirect " << response_code << ")." << endl; | 356 cout << "Request failed (redirect " << response_code << ")." << endl; |
357 return 1; | 357 return 1; |
358 } | 358 } |
359 } else { | 359 } else { |
360 cerr << "Request failed (" << response_code << ")." << endl; | 360 cerr << "Request failed (" << response_code << ")." << endl; |
361 return 1; | 361 return 1; |
362 } | 362 } |
363 } | 363 } |
OLD | NEW |