| Index: net/tools/quic/quic_simple_client_bin.cc
|
| diff --git a/net/tools/quic/quic_simple_client_bin.cc b/net/tools/quic/quic_simple_client_bin.cc
|
| index 560d607b7bf182573bed886a2a89da761c32af0b..ffa5e54d2899bc056fde71d5d65e684b330903fe 100644
|
| --- a/net/tools/quic/quic_simple_client_bin.cc
|
| +++ b/net/tools/quic/quic_simple_client_bin.cc
|
| @@ -44,21 +44,17 @@
|
| #include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop/message_loop.h"
|
| -#include "base/strings/string_number_conversions.h"
|
| -#include "base/strings/string_split.h"
|
| -#include "base/strings/string_util.h"
|
| -#include "net/base/ip_address.h"
|
| -#include "net/base/ip_endpoint.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/base/privacy_mode.h"
|
| #include "net/cert/cert_verifier.h"
|
| #include "net/cert/multi_log_ct_verifier.h"
|
| -#include "net/http/http_request_info.h"
|
| #include "net/http/transport_security_state.h"
|
| #include "net/quic/chromium/crypto/proof_verifier_chromium.h"
|
| #include "net/quic/core/quic_error_codes.h"
|
| #include "net/quic/core/quic_packets.h"
|
| #include "net/quic/core/quic_server_id.h"
|
| +#include "net/quic/platform/api/quic_socket_address.h"
|
| +#include "net/quic/platform/api/quic_str_cat.h"
|
| #include "net/quic/platform/api/quic_text_utils.h"
|
| #include "net/spdy/spdy_header_block.h"
|
| #include "net/spdy/spdy_http_utils.h"
|
| @@ -74,6 +70,7 @@ using net::MultiLogCTVerifier;
|
| using net::ProofVerifier;
|
| using net::ProofVerifierChromium;
|
| using net::QuicTextUtils;
|
| +using net::SpdyHeaderBlock;
|
| using net::TransportSecurityState;
|
| using std::cout;
|
| using std::cerr;
|
| @@ -223,10 +220,8 @@ int main(int argc, char* argv[]) {
|
| base::MessageLoopForIO message_loop;
|
|
|
| // Determine IP address to connect to from supplied hostname.
|
| - net::IPAddress ip_addr;
|
| + net::QuicIpAddress ip_addr;
|
|
|
| - // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus
|
| - // protocol is required in the URL.
|
| GURL url(urls[0]);
|
| string host = FLAGS_host;
|
| if (host.empty()) {
|
| @@ -236,7 +231,7 @@ int main(int argc, char* argv[]) {
|
| if (port == 0) {
|
| port = url.EffectiveIntPort();
|
| }
|
| - if (!ip_addr.AssignFromIPLiteral(host)) {
|
| + if (!ip_addr.FromString(host)) {
|
| net::AddressList addresses;
|
| int rv = net::SynchronousHostResolver::Resolve(host, &addresses);
|
| if (rv != net::OK) {
|
| @@ -244,10 +239,11 @@ int main(int argc, char* argv[]) {
|
| << "' : " << net::ErrorToShortString(rv);
|
| return 1;
|
| }
|
| - ip_addr = addresses[0].address();
|
| + ip_addr =
|
| + net::QuicIpAddress(net::QuicIpAddressImpl(addresses[0].address()));
|
| }
|
|
|
| - string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
|
| + string host_port = net::QuicStrCat(ip_addr.ToString(), ":", port);
|
| VLOG(1) << "Resolved " << host << " to " << host_port << endl;
|
|
|
| // Build the client, and try to connect.
|
| @@ -272,7 +268,7 @@ int main(int argc, char* argv[]) {
|
| cert_verifier.get(), ct_policy_enforcer.get(),
|
| transport_security_state.get(), ct_verifier.get()));
|
| }
|
| - net::QuicSimpleClient client(net::IPEndPoint(ip_addr, port), server_id,
|
| + net::QuicSimpleClient client(net::QuicSocketAddress(ip_addr, port), server_id,
|
| versions, std::move(proof_verifier));
|
| client.set_initial_max_packet_length(
|
| FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize);
|
| @@ -302,36 +298,28 @@ int main(int argc, char* argv[]) {
|
| }
|
|
|
| // Construct a GET or POST request for supplied URL.
|
| - net::HttpRequestInfo request;
|
| - request.method = body.empty() ? "GET" : "POST";
|
| - request.url = url;
|
| + SpdyHeaderBlock header_block;
|
| + header_block[":method"] = body.empty() ? "GET" : "POST";
|
| + header_block[":scheme"] = url.scheme();
|
| + header_block[":authority"] = url.host();
|
| + header_block[":path"] = url.path();
|
|
|
| // Append any additional headers supplied on the command line.
|
| - for (const std::string& header :
|
| - base::SplitString(FLAGS_headers, ";", base::KEEP_WHITESPACE,
|
| - base::SPLIT_WANT_NONEMPTY)) {
|
| - string sp;
|
| - base::TrimWhitespaceASCII(header, base::TRIM_ALL, &sp);
|
| + for (StringPiece sp : QuicTextUtils::Split(FLAGS_headers, ';')) {
|
| + QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&sp);
|
| if (sp.empty()) {
|
| continue;
|
| }
|
| - std::vector<string> kv =
|
| - base::SplitString(sp, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| - CHECK_EQ(2u, kv.size());
|
| - string key;
|
| - base::TrimWhitespaceASCII(kv[0], base::TRIM_ALL, &key);
|
| - string value;
|
| - base::TrimWhitespaceASCII(kv[1], base::TRIM_ALL, &value);
|
| - request.extra_headers.SetHeader(key, value);
|
| + std::vector<StringPiece> kv = QuicTextUtils::Split(sp, ':');
|
| + QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]);
|
| + QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]);
|
| + header_block[kv[0]] = kv[1];
|
| }
|
|
|
| // Make sure to store the response, for later output.
|
| client.set_store_response(true);
|
|
|
| // Send the request.
|
| - net::SpdyHeaderBlock header_block;
|
| - net::CreateSpdyHeadersFromHttpRequest(request, request.extra_headers,
|
| - /*direct=*/true, &header_block);
|
| client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true);
|
|
|
| // Print request and response details.
|
| @@ -356,6 +344,7 @@ int main(int argc, char* argv[]) {
|
| } else {
|
| cout << "body: " << response_body << endl;
|
| }
|
| + cout << "trailers: " << client.latest_response_trailers() << endl;
|
| }
|
|
|
| size_t response_code = client.latest_response_code();
|
|
|