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/quic/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 return rv; | 437 return rv; |
438 } | 438 } |
439 | 439 |
440 int QuicHttpStream::DoSendHeaders() { | 440 int QuicHttpStream::DoSendHeaders() { |
441 if (!stream_) | 441 if (!stream_) |
442 return ERR_UNEXPECTED; | 442 return ERR_UNEXPECTED; |
443 | 443 |
444 // Log the actual request with the URL Request's net log. | 444 // Log the actual request with the URL Request's net log. |
445 stream_net_log_.AddEvent( | 445 stream_net_log_.AddEvent( |
446 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, | 446 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, |
447 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, | 447 base::Bind(QuicRequestNetLogCallback, stream_->id(), &request_headers_, |
448 priority_)); | 448 priority_)); |
449 // Also log to the QuicSession's net log. | 449 // Also log to the QuicSession's net log. |
450 stream_->net_log().AddEvent( | 450 stream_->net_log().AddEvent( |
451 NetLog::TYPE_QUIC_HTTP_STREAM_SEND_REQUEST_HEADERS, | 451 NetLog::TYPE_QUIC_HTTP_STREAM_SEND_REQUEST_HEADERS, |
452 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, | 452 base::Bind(QuicRequestNetLogCallback, stream_->id(), &request_headers_, |
453 priority_)); | 453 priority_)); |
454 | 454 |
455 bool has_upload_data = request_body_stream_ != nullptr; | 455 bool has_upload_data = request_body_stream_ != nullptr; |
456 | 456 |
457 next_state_ = STATE_SEND_HEADERS_COMPLETE; | 457 next_state_ = STATE_SEND_HEADERS_COMPLETE; |
458 int rv = stream_->WriteHeaders(request_headers_, !has_upload_data, nullptr); | 458 int rv = stream_->WriteHeaders(request_headers_, !has_upload_data, nullptr); |
459 request_headers_.clear(); | 459 request_headers_.clear(); |
460 return rv; | 460 return rv; |
461 } | 461 } |
462 | 462 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // Save the remaining received data. | 543 // Save the remaining received data. |
544 size_t delta = read_buf_len - len; | 544 size_t delta = read_buf_len - len; |
545 if (delta > 0) { | 545 if (delta > 0) { |
546 BufferResponseBody(data + len, delta); | 546 BufferResponseBody(data + len, delta); |
547 } | 547 } |
548 | 548 |
549 // The URLRequest logs these headers, so only log to the QuicSession's | 549 // The URLRequest logs these headers, so only log to the QuicSession's |
550 // net log. | 550 // net log. |
551 stream_->net_log().AddEvent( | 551 stream_->net_log().AddEvent( |
552 NetLog::TYPE_QUIC_HTTP_STREAM_READ_RESPONSE_HEADERS, | 552 NetLog::TYPE_QUIC_HTTP_STREAM_READ_RESPONSE_HEADERS, |
553 base::Bind(&SpdyHeaderBlockNetLogCallback, &headers)); | 553 base::Bind(SpdyHeaderBlockNetLogCallback, &headers)); |
554 | 554 |
555 if (!SpdyHeadersToHttpResponse(headers, GetSpdyVersion(), response_info_)) { | 555 if (!SpdyHeadersToHttpResponse(headers, GetSpdyVersion(), response_info_)) { |
556 DLOG(WARNING) << "Invalid headers"; | 556 DLOG(WARNING) << "Invalid headers"; |
557 return ERR_QUIC_PROTOCOL_ERROR; | 557 return ERR_QUIC_PROTOCOL_ERROR; |
558 } | 558 } |
559 // Put the peer's IP address and port into the response. | 559 // Put the peer's IP address and port into the response. |
560 IPEndPoint address = session_->peer_address(); | 560 IPEndPoint address = session_->peer_address(); |
561 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); | 561 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); |
562 response_info_->connection_info = | 562 response_info_->connection_info = |
563 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; | 563 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; |
(...skipping 14 matching lines...) Expand all Loading... |
578 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); | 578 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); |
579 memcpy(io_buffer->data(), data, length); | 579 memcpy(io_buffer->data(), data, length); |
580 response_body_.push_back(make_scoped_refptr(io_buffer)); | 580 response_body_.push_back(make_scoped_refptr(io_buffer)); |
581 } | 581 } |
582 | 582 |
583 SpdyMajorVersion QuicHttpStream::GetSpdyVersion() { | 583 SpdyMajorVersion QuicHttpStream::GetSpdyVersion() { |
584 return SpdyUtils::GetSpdyVersionForQuicVersion(stream_->version()); | 584 return SpdyUtils::GetSpdyVersionForQuicVersion(stream_->version()); |
585 } | 585 } |
586 | 586 |
587 } // namespace net | 587 } // namespace net |
OLD | NEW |