| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 request.extra_headers.SetHeader(key, value); | 311 request.extra_headers.SetHeader(key, value); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Make sure to store the response, for later output. | 314 // Make sure to store the response, for later output. |
| 315 client.set_store_response(true); | 315 client.set_store_response(true); |
| 316 | 316 |
| 317 // Send the request. | 317 // Send the request. |
| 318 net::SpdyHeaderBlock header_block; | 318 net::SpdyHeaderBlock header_block; |
| 319 net::CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, | 319 net::CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, |
| 320 /*direct=*/true, &header_block); | 320 /*direct=*/true, &header_block); |
| 321 client.SendRequestAndWaitForResponse(request, body, /*fin=*/true); | 321 client.SendRequestAndWaitForResponse(header_block, body, /*fin=*/true); |
| 322 | 322 |
| 323 // Print request and response details. | 323 // Print request and response details. |
| 324 if (!FLAGS_quiet) { | 324 if (!FLAGS_quiet) { |
| 325 cout << "Request:" << endl; | 325 cout << "Request:" << endl; |
| 326 cout << "headers:" << header_block.DebugString(); | 326 cout << "headers:" << header_block.DebugString(); |
| 327 if (!FLAGS_body_hex.empty()) { | 327 if (!FLAGS_body_hex.empty()) { |
| 328 // Print the user provided hex, rather than binary body. | 328 // Print the user provided hex, rather than binary body. |
| 329 cout << "body:\n" | 329 cout << "body:\n" |
| 330 << net::QuicUtils::HexDump(net::QuicUtils::HexDecode(FLAGS_body_hex)) | 330 << net::QuicUtils::HexDump(net::QuicUtils::HexDecode(FLAGS_body_hex)) |
| 331 << endl; | 331 << endl; |
| (...skipping 22 matching lines...) Expand all 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 |