Index: net/tools/quic/quic_client.cc |
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc |
index 741d24b9b074ceddcdd4b6ae11e75997aee7af4d..68cdf001796ed525cfe47651fde4dca293bbcef0 100644 |
--- a/net/tools/quic/quic_client.cc |
+++ b/net/tools/quic/quic_client.cc |
@@ -32,7 +32,8 @@ const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
QuicClient::QuicClient(IPEndPoint server_address, |
const string& server_hostname, |
- const QuicVersion version) |
+ const QuicVersion version, |
+ bool print_response) |
: server_address_(server_address), |
server_hostname_(server_hostname), |
local_port_(0), |
@@ -40,7 +41,8 @@ QuicClient::QuicClient(IPEndPoint server_address, |
initialized_(false), |
packets_dropped_(0), |
overflow_supported_(false), |
- version_(version) { |
+ version_(version), |
+ print_response_(print_response) { |
config_.SetDefaults(); |
} |
@@ -56,7 +58,8 @@ QuicClient::QuicClient(IPEndPoint server_address, |
initialized_(false), |
packets_dropped_(0), |
overflow_supported_(false), |
- version_(version) { |
+ version_(version), |
+ print_response_(false) { |
} |
QuicClient::~QuicClient() { |
@@ -178,10 +181,12 @@ void QuicClient::Disconnect() { |
void QuicClient::SendRequestsAndWaitForResponse( |
const CommandLine::StringVector& args) { |
- for (uint32_t i = 0; i < args.size(); i++) { |
+ for (size_t i = 0; i < args.size(); i++) { |
BalsaHeaders headers; |
headers.SetRequestFirstlineFromStringPieces("GET", args[i], "HTTP/1.1"); |
- CreateReliableClientStream()->SendRequest(headers, "", true); |
+ QuicReliableClientStream* stream = CreateReliableClientStream(); |
+ stream->SendRequest(headers, "", true); |
+ stream->set_visitor(this); |
} |
while (WaitForEvents()) { } |
@@ -233,6 +238,24 @@ void QuicClient::OnEvent(int fd, EpollEvent* event) { |
} |
} |
+void QuicClient::OnClose(ReliableQuicStream* stream) { |
+ if (!print_response_) { |
+ return; |
+ } |
+ |
+ QuicReliableClientStream* client_stream = |
+ static_cast<QuicReliableClientStream*>(stream); |
+ const BalsaHeaders& headers = client_stream->headers(); |
+ printf("%s\n", headers.first_line().as_string().c_str()); |
+ for (BalsaHeaders::const_header_lines_iterator i = |
+ headers.header_lines_begin(); |
+ i != headers.header_lines_end(); ++i) { |
+ printf("%s: %s\n", i->first.as_string().c_str(), |
+ i->second.as_string().c_str()); |
+ } |
+ printf("%s\n", client_stream->data().c_str()); |
+} |
+ |
QuicPacketCreator::Options* QuicClient::options() { |
if (session() == NULL) { |
return NULL; |