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

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

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 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_base.cc ('k') | net/tools/quic/quic_dispatcher.cc » ('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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "net/cert/ct_known_logs.h" 49 #include "net/cert/ct_known_logs.h"
50 #include "net/cert/ct_log_verifier.h" 50 #include "net/cert/ct_log_verifier.h"
51 #include "net/cert/multi_log_ct_verifier.h" 51 #include "net/cert/multi_log_ct_verifier.h"
52 #include "net/http/transport_security_state.h" 52 #include "net/http/transport_security_state.h"
53 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" 53 #include "net/quic/chromium/crypto/proof_verifier_chromium.h"
54 #include "net/quic/core/quic_flags.h" 54 #include "net/quic/core/quic_flags.h"
55 #include "net/quic/core/quic_packets.h" 55 #include "net/quic/core/quic_packets.h"
56 #include "net/quic/core/quic_server_id.h" 56 #include "net/quic/core/quic_server_id.h"
57 #include "net/quic/platform/api/quic_socket_address.h" 57 #include "net/quic/platform/api/quic_socket_address.h"
58 #include "net/quic/platform/api/quic_str_cat.h" 58 #include "net/quic/platform/api/quic_str_cat.h"
59 #include "net/quic/platform/api/quic_string_piece.h"
59 #include "net/quic/platform/api/quic_text_utils.h" 60 #include "net/quic/platform/api/quic_text_utils.h"
60 #include "net/quic/platform/api/quic_url.h" 61 #include "net/quic/platform/api/quic_url.h"
61 #include "net/spdy/spdy_header_block.h" 62 #include "net/spdy/spdy_header_block.h"
62 #include "net/tools/epoll_server/epoll_server.h" 63 #include "net/tools/epoll_server/epoll_server.h"
63 #include "net/tools/quic/quic_client.h" 64 #include "net/tools/quic/quic_client.h"
64 #include "net/tools/quic/synchronous_host_resolver.h" 65 #include "net/tools/quic/synchronous_host_resolver.h"
65 66
66 using base::StringPiece;
67 using net::CertVerifier; 67 using net::CertVerifier;
68 using net::CTPolicyEnforcer; 68 using net::CTPolicyEnforcer;
69 using net::CTVerifier; 69 using net::CTVerifier;
70 using net::MultiLogCTVerifier; 70 using net::MultiLogCTVerifier;
71 using net::ProofVerifier; 71 using net::ProofVerifier;
72 using net::ProofVerifierChromium; 72 using net::ProofVerifierChromium;
73 using net::QuicStringPiece;
73 using net::QuicTextUtils; 74 using net::QuicTextUtils;
74 using net::QuicUrl; 75 using net::QuicUrl;
75 using net::SpdyHeaderBlock; 76 using net::SpdyHeaderBlock;
76 using net::TransportSecurityState; 77 using net::TransportSecurityState;
77 using std::cout; 78 using std::cout;
78 using std::cerr; 79 using std::cerr;
79 using std::endl; 80 using std::endl;
80 using std::string; 81 using std::string;
81 82
82 // The IP or hostname the quic client will connect to. 83 // The IP or hostname the quic client will connect to.
(...skipping 21 matching lines...) Expand all
104 // Initial MTU of the connection. 105 // Initial MTU of the connection.
105 int32_t FLAGS_initial_mtu = 0; 106 int32_t FLAGS_initial_mtu = 0;
106 107
107 class FakeProofVerifier : public ProofVerifier { 108 class FakeProofVerifier : public ProofVerifier {
108 public: 109 public:
109 net::QuicAsyncStatus VerifyProof( 110 net::QuicAsyncStatus VerifyProof(
110 const string& /*hostname*/, 111 const string& /*hostname*/,
111 const uint16_t /*port*/, 112 const uint16_t /*port*/,
112 const string& /*server_config*/, 113 const string& /*server_config*/,
113 net::QuicVersion /*quic_version*/, 114 net::QuicVersion /*quic_version*/,
114 StringPiece /*chlo_hash*/, 115 QuicStringPiece /*chlo_hash*/,
115 const std::vector<string>& /*certs*/, 116 const std::vector<string>& /*certs*/,
116 const string& /*cert_sct*/, 117 const string& /*cert_sct*/,
117 const string& /*signature*/, 118 const string& /*signature*/,
118 const net::ProofVerifyContext* /*context*/, 119 const net::ProofVerifyContext* /*context*/,
119 string* /*error_details*/, 120 string* /*error_details*/,
120 std::unique_ptr<net::ProofVerifyDetails>* /*details*/, 121 std::unique_ptr<net::ProofVerifyDetails>* /*details*/,
121 std::unique_ptr<net::ProofVerifierCallback> /*callback*/) override { 122 std::unique_ptr<net::ProofVerifierCallback> /*callback*/) override {
122 return net::QUIC_SUCCESS; 123 return net::QUIC_SUCCESS;
123 } 124 }
124 125
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 303 }
303 304
304 // Construct a GET or POST request for supplied URL. 305 // Construct a GET or POST request for supplied URL.
305 SpdyHeaderBlock header_block; 306 SpdyHeaderBlock header_block;
306 header_block[":method"] = body.empty() ? "GET" : "POST"; 307 header_block[":method"] = body.empty() ? "GET" : "POST";
307 header_block[":scheme"] = url.scheme(); 308 header_block[":scheme"] = url.scheme();
308 header_block[":authority"] = url.HostPort(); 309 header_block[":authority"] = url.HostPort();
309 header_block[":path"] = url.PathParamsQuery(); 310 header_block[":path"] = url.PathParamsQuery();
310 311
311 // Append any additional headers supplied on the command line. 312 // Append any additional headers supplied on the command line.
312 for (StringPiece sp : QuicTextUtils::Split(FLAGS_headers, ';')) { 313 for (QuicStringPiece sp : QuicTextUtils::Split(FLAGS_headers, ';')) {
313 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&sp); 314 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&sp);
314 if (sp.empty()) { 315 if (sp.empty()) {
315 continue; 316 continue;
316 } 317 }
317 std::vector<StringPiece> kv = QuicTextUtils::Split(sp, ':'); 318 std::vector<QuicStringPiece> kv = QuicTextUtils::Split(sp, ':');
318 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]); 319 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]);
319 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]); 320 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]);
320 header_block[kv[0]] = kv[1]; 321 header_block[kv[0]] = kv[1];
321 } 322 }
322 323
323 // Make sure to store the response, for later output. 324 // Make sure to store the response, for later output.
324 client.set_store_response(true); 325 client.set_store_response(true);
325 326
326 // Send the request. 327 // Send the request.
327 client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true); 328 client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return 0; 369 return 0;
369 } else { 370 } else {
370 cout << "Request failed (redirect " << response_code << ")." << endl; 371 cout << "Request failed (redirect " << response_code << ")." << endl;
371 return 1; 372 return 1;
372 } 373 }
373 } else { 374 } else {
374 cerr << "Request failed (" << response_code << ")." << endl; 375 cerr << "Request failed (" << response_code << ")." << endl;
375 return 1; 376 return 1;
376 } 377 }
377 } 378 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_base.cc ('k') | net/tools/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698