OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_client_promised_info.h" | 5 #include "net/quic/quic_client_promised_info.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/spdy_utils.h" | 8 #include "net/quic/spdy_utils.h" |
9 | 9 |
10 using net::SpdyHeaderBlock; | 10 using net::SpdyHeaderBlock; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 if (!SpdyUtils::UrlIsValid(headers)) { | 50 if (!SpdyUtils::UrlIsValid(headers)) { |
51 DVLOG(1) << "Promise for stream " << id_ << " has invalid URL " << url_; | 51 DVLOG(1) << "Promise for stream " << id_ << " has invalid URL " << url_; |
52 Reset(QUIC_INVALID_PROMISE_URL); | 52 Reset(QUIC_INVALID_PROMISE_URL); |
53 return; | 53 return; |
54 } | 54 } |
55 if (!session_->IsAuthorized(SpdyUtils::GetHostNameFromHeaderBlock(headers))) { | 55 if (!session_->IsAuthorized(SpdyUtils::GetHostNameFromHeaderBlock(headers))) { |
56 Reset(QUIC_UNAUTHORIZED_PROMISE_URL); | 56 Reset(QUIC_UNAUTHORIZED_PROMISE_URL); |
57 return; | 57 return; |
58 } | 58 } |
59 request_headers_.reset(new SpdyHeaderBlock(headers)); | 59 request_headers_.reset(new SpdyHeaderBlock(headers.Clone())); |
60 } | 60 } |
61 | 61 |
62 void QuicClientPromisedInfo::OnResponseHeaders(const SpdyHeaderBlock& headers) { | 62 void QuicClientPromisedInfo::OnResponseHeaders(const SpdyHeaderBlock& headers) { |
63 response_headers_.reset(new SpdyHeaderBlock(headers)); | 63 response_headers_.reset(new SpdyHeaderBlock(headers.Clone())); |
64 if (client_request_delegate_) { | 64 if (client_request_delegate_) { |
65 // We already have a client request waiting. | 65 // We already have a client request waiting. |
66 FinalValidation(); | 66 FinalValidation(); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 void QuicClientPromisedInfo::Reset(QuicRstStreamErrorCode error_code) { | 70 void QuicClientPromisedInfo::Reset(QuicRstStreamErrorCode error_code) { |
71 QuicClientPushPromiseIndex::Delegate* delegate = client_request_delegate_; | 71 QuicClientPushPromiseIndex::Delegate* delegate = client_request_delegate_; |
72 session_->ResetPromised(id_, error_code); | 72 session_->ResetPromised(id_, error_code); |
73 session_->DeletePromised(this); | 73 session_->DeletePromised(this); |
(...skipping 26 matching lines...) Expand all Loading... |
100 | 100 |
101 QuicAsyncStatus QuicClientPromisedInfo::HandleClientRequest( | 101 QuicAsyncStatus QuicClientPromisedInfo::HandleClientRequest( |
102 const SpdyHeaderBlock& request_headers, | 102 const SpdyHeaderBlock& request_headers, |
103 QuicClientPushPromiseIndex::Delegate* delegate) { | 103 QuicClientPushPromiseIndex::Delegate* delegate) { |
104 if (session_->IsClosedStream(id_)) { | 104 if (session_->IsClosedStream(id_)) { |
105 // There was a RST on the response stream. | 105 // There was a RST on the response stream. |
106 session_->DeletePromised(this); | 106 session_->DeletePromised(this); |
107 return QUIC_FAILURE; | 107 return QUIC_FAILURE; |
108 } | 108 } |
109 client_request_delegate_ = delegate; | 109 client_request_delegate_ = delegate; |
110 client_request_headers_.reset(new SpdyHeaderBlock(request_headers)); | 110 client_request_headers_.reset(new SpdyHeaderBlock(request_headers.Clone())); |
111 if (!response_headers_) { | 111 if (!response_headers_) { |
112 return QUIC_PENDING; | 112 return QUIC_PENDING; |
113 } | 113 } |
114 return FinalValidation(); | 114 return FinalValidation(); |
115 } | 115 } |
116 | 116 |
117 void QuicClientPromisedInfo::Cancel() { | 117 void QuicClientPromisedInfo::Cancel() { |
118 // Don't fire OnRendezvousResult() for client initiated cancel. | 118 // Don't fire OnRendezvousResult() for client initiated cancel. |
119 client_request_delegate_ = nullptr; | 119 client_request_delegate_ = nullptr; |
120 Reset(QUIC_STREAM_CANCELLED); | 120 Reset(QUIC_STREAM_CANCELLED); |
121 } | 121 } |
122 | 122 |
123 } // namespace net | 123 } // namespace net |
OLD | NEW |