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 #include "net/tools/quic/quic_simple_client.h" | 5 #include "net/tools/quic/quic_simple_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 void QuicSimpleClient::SendRequest(const HttpRequestInfo& headers, | 249 void QuicSimpleClient::SendRequest(const HttpRequestInfo& headers, |
250 base::StringPiece body, | 250 base::StringPiece body, |
251 bool fin) { | 251 bool fin) { |
252 QuicSpdyClientStream* stream = CreateReliableClientStream(); | 252 QuicSpdyClientStream* stream = CreateReliableClientStream(); |
253 if (stream == nullptr) { | 253 if (stream == nullptr) { |
254 LOG(DFATAL) << "stream creation failed!"; | 254 LOG(DFATAL) << "stream creation failed!"; |
255 return; | 255 return; |
256 } | 256 } |
257 SpdyHeaderBlock header_block; | 257 SpdyHeaderBlock header_block; |
258 CreateSpdyHeadersFromHttpRequest(headers, headers.extra_headers, net::HTTP2, | 258 CreateSpdyHeadersFromHttpRequest(headers, headers.extra_headers, true, |
259 true, &header_block); | 259 &header_block); |
260 stream->set_visitor(this); | 260 stream->set_visitor(this); |
261 stream->SendRequest(std::move(header_block), body, fin); | 261 stream->SendRequest(std::move(header_block), body, fin); |
262 if (FLAGS_enable_quic_stateless_reject_support) { | 262 if (FLAGS_enable_quic_stateless_reject_support) { |
263 // Record this in case we need to resend. | 263 // Record this in case we need to resend. |
264 auto* new_headers = new HttpRequestInfo; | 264 auto* new_headers = new HttpRequestInfo; |
265 *new_headers = headers; | 265 *new_headers = headers; |
266 auto* data_to_resend = | 266 auto* data_to_resend = |
267 new ClientQuicDataToResend(new_headers, body, fin, this); | 267 new ClientQuicDataToResend(new_headers, body, fin, this); |
268 MaybeAddQuicDataToResend(data_to_resend); | 268 MaybeAddQuicDataToResend(data_to_resend); |
269 } | 269 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 session()->connection()->SetQuicPacketWriter(writer, false); | 341 session()->connection()->SetQuicPacketWriter(writer, false); |
342 | 342 |
343 return true; | 343 return true; |
344 } | 344 } |
345 | 345 |
346 void QuicSimpleClient::OnClose(QuicSpdyStream* stream) { | 346 void QuicSimpleClient::OnClose(QuicSpdyStream* stream) { |
347 DCHECK(stream != nullptr); | 347 DCHECK(stream != nullptr); |
348 QuicSpdyClientStream* client_stream = | 348 QuicSpdyClientStream* client_stream = |
349 static_cast<QuicSpdyClientStream*>(stream); | 349 static_cast<QuicSpdyClientStream*>(stream); |
350 HttpResponseInfo response; | 350 HttpResponseInfo response; |
351 SpdyHeadersToHttpResponse(client_stream->response_headers(), net::HTTP2, | 351 SpdyHeadersToHttpResponse(client_stream->response_headers(), &response); |
352 &response); | |
353 if (response_listener_.get() != nullptr) { | 352 if (response_listener_.get() != nullptr) { |
354 response_listener_->OnCompleteResponse(stream->id(), *response.headers, | 353 response_listener_->OnCompleteResponse(stream->id(), *response.headers, |
355 client_stream->data()); | 354 client_stream->data()); |
356 } | 355 } |
357 | 356 |
358 // Store response headers and body. | 357 // Store response headers and body. |
359 if (store_response_) { | 358 if (store_response_) { |
360 latest_response_code_ = client_stream->response_code(); | 359 latest_response_code_ = client_stream->response_code(); |
361 response.headers->GetNormalizedHeaders(&latest_response_headers_); | 360 response.headers->GetNormalizedHeaders(&latest_response_headers_); |
362 latest_response_body_ = client_stream->data(); | 361 latest_response_body_ = client_stream->data(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 session()->connection()->ProcessUdpPacket(local_address, peer_address, | 406 session()->connection()->ProcessUdpPacket(local_address, peer_address, |
408 packet); | 407 packet); |
409 if (!session()->connection()->connected()) { | 408 if (!session()->connection()->connected()) { |
410 return false; | 409 return false; |
411 } | 410 } |
412 | 411 |
413 return true; | 412 return true; |
414 } | 413 } |
415 | 414 |
416 } // namespace net | 415 } // namespace net |
OLD | NEW |