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

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

Issue 1357953002: Replace the existing SpdyHeaderBlock typedef with a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add NET_EXPORT to fix compile error on win_chromium_compile_dbg_ng. Created 5 years, 2 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_simple_client.cc ('k') | net/tools/quic/quic_spdy_client_stream.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "net/base/net_errors.h" 51 #include "net/base/net_errors.h"
52 #include "net/base/privacy_mode.h" 52 #include "net/base/privacy_mode.h"
53 #include "net/cert/cert_verifier.h" 53 #include "net/cert/cert_verifier.h"
54 #include "net/http/http_request_info.h" 54 #include "net/http/http_request_info.h"
55 #include "net/http/transport_security_state.h" 55 #include "net/http/transport_security_state.h"
56 #include "net/log/net_log.h" 56 #include "net/log/net_log.h"
57 #include "net/quic/crypto/proof_verifier_chromium.h" 57 #include "net/quic/crypto/proof_verifier_chromium.h"
58 #include "net/quic/quic_protocol.h" 58 #include "net/quic/quic_protocol.h"
59 #include "net/quic/quic_server_id.h" 59 #include "net/quic/quic_server_id.h"
60 #include "net/quic/quic_utils.h" 60 #include "net/quic/quic_utils.h"
61 #include "net/spdy/spdy_header_block.h"
61 #include "net/spdy/spdy_http_utils.h" 62 #include "net/spdy/spdy_http_utils.h"
62 #include "net/tools/quic/quic_simple_client.h" 63 #include "net/tools/quic/quic_simple_client.h"
63 #include "net/tools/quic/synchronous_host_resolver.h" 64 #include "net/tools/quic/synchronous_host_resolver.h"
64 #include "url/gurl.h" 65 #include "url/gurl.h"
65 66
66 using base::StringPiece; 67 using base::StringPiece;
67 using net::CertVerifier; 68 using net::CertVerifier;
68 using net::ProofVerifierChromium; 69 using net::ProofVerifierChromium;
69 using net::TransportSecurityState; 70 using net::TransportSecurityState;
70 using std::cout; 71 using std::cout;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 net::SpdyHeaderBlock header_block; 272 net::SpdyHeaderBlock header_block;
272 net::CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, 273 net::CreateSpdyHeadersFromHttpRequest(request, request.extra_headers,
273 net::HTTP2, /*direct=*/true, 274 net::HTTP2, /*direct=*/true,
274 &header_block); 275 &header_block);
275 client.SendRequestAndWaitForResponse(request, FLAGS_body, /*fin=*/true); 276 client.SendRequestAndWaitForResponse(request, FLAGS_body, /*fin=*/true);
276 277
277 // Print request and response details. 278 // Print request and response details.
278 if (!FLAGS_quiet) { 279 if (!FLAGS_quiet) {
279 cout << "Request:" << endl; 280 cout << "Request:" << endl;
280 cout << "headers:" << endl; 281 cout << "headers:" << endl;
281 for (const std::pair<string, string>& kv : header_block) { 282 for (const auto& kv : header_block) {
282 cout << " " << kv.first << ": " << kv.second << endl; 283 cout << " " << kv.first << ": " << kv.second << endl;
283 } 284 }
284 cout << "body: " << FLAGS_body << endl; 285 cout << "body: " << FLAGS_body << endl;
285 cout << endl; 286 cout << endl;
286 cout << "Response:" << endl; 287 cout << "Response:" << endl;
287 cout << "headers: " << client.latest_response_headers() << endl; 288 cout << "headers: " << client.latest_response_headers() << endl;
288 cout << "body: " << client.latest_response_body() << endl; 289 cout << "body: " << client.latest_response_body() << endl;
289 } 290 }
290 291
291 size_t response_code = client.latest_response_code(); 292 size_t response_code = client.latest_response_code();
292 if (response_code >= 200 && response_code < 300) { 293 if (response_code >= 200 && response_code < 300) {
293 cout << "Request succeeded (" << response_code << ")." << endl; 294 cout << "Request succeeded (" << response_code << ")." << endl;
294 return 0; 295 return 0;
295 } else if (response_code >= 300 && response_code < 400) { 296 } else if (response_code >= 300 && response_code < 400) {
296 if (FLAGS_redirect_is_success) { 297 if (FLAGS_redirect_is_success) {
297 cout << "Request succeeded (redirect " << response_code << ")." << endl; 298 cout << "Request succeeded (redirect " << response_code << ")." << endl;
298 return 0; 299 return 0;
299 } else { 300 } else {
300 cout << "Request failed (redirect " << response_code << ")." << endl; 301 cout << "Request failed (redirect " << response_code << ")." << endl;
301 return 1; 302 return 1;
302 } 303 }
303 } else { 304 } else {
304 cerr << "Request failed (" << response_code << ")." << endl; 305 cerr << "Request failed (" << response_code << ")." << endl;
305 return 1; 306 return 1;
306 } 307 }
307 } 308 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_client.cc ('k') | net/tools/quic/quic_spdy_client_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698