| 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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Pushed streams do not send any data, and should always be | 268 // Pushed streams do not send any data, and should always be |
| 269 // idle. However, we still want to return ERR_IO_PENDING to mimic | 269 // idle. However, we still want to return ERR_IO_PENDING to mimic |
| 270 // non-push behavior. The callback will be called when the | 270 // non-push behavior. The callback will be called when the |
| 271 // response is received. | 271 // response is received. |
| 272 CHECK(response_callback_.is_null()); | 272 CHECK(response_callback_.is_null()); |
| 273 response_callback_ = callback; | 273 response_callback_ = callback; |
| 274 return ERR_IO_PENDING; | 274 return ERR_IO_PENDING; |
| 275 } | 275 } |
| 276 | 276 |
| 277 std::unique_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 277 std::unique_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
| 278 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, | 278 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, direct_, |
| 279 stream_->GetProtocolVersion(), direct_, | |
| 280 headers.get()); | 279 headers.get()); |
| 281 stream_->net_log().AddEvent( | 280 stream_->net_log().AddEvent( |
| 282 NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS, | 281 NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS, |
| 283 base::Bind(&SpdyHeaderBlockNetLogCallback, headers.get())); | 282 base::Bind(&SpdyHeaderBlockNetLogCallback, headers.get())); |
| 284 result = stream_->SendRequestHeaders( | 283 result = stream_->SendRequestHeaders( |
| 285 std::move(headers), | 284 std::move(headers), |
| 286 HasUploadData() ? MORE_DATA_TO_SEND : NO_MORE_DATA_TO_SEND); | 285 HasUploadData() ? MORE_DATA_TO_SEND : NO_MORE_DATA_TO_SEND); |
| 287 | 286 |
| 288 if (result == ERR_IO_PENDING) { | 287 if (result == ERR_IO_PENDING) { |
| 289 CHECK(request_callback_.is_null()); | 288 CHECK(request_callback_.is_null()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 313 SpdyResponseHeadersStatus SpdyHttpStream::OnResponseHeadersUpdated( | 312 SpdyResponseHeadersStatus SpdyHttpStream::OnResponseHeadersUpdated( |
| 314 const SpdyHeaderBlock& response_headers) { | 313 const SpdyHeaderBlock& response_headers) { |
| 315 CHECK_EQ(response_headers_status_, RESPONSE_HEADERS_ARE_INCOMPLETE); | 314 CHECK_EQ(response_headers_status_, RESPONSE_HEADERS_ARE_INCOMPLETE); |
| 316 | 315 |
| 317 if (!response_info_) { | 316 if (!response_info_) { |
| 318 DCHECK_EQ(stream_->type(), SPDY_PUSH_STREAM); | 317 DCHECK_EQ(stream_->type(), SPDY_PUSH_STREAM); |
| 319 push_response_info_.reset(new HttpResponseInfo); | 318 push_response_info_.reset(new HttpResponseInfo); |
| 320 response_info_ = push_response_info_.get(); | 319 response_info_ = push_response_info_.get(); |
| 321 } | 320 } |
| 322 | 321 |
| 323 if (!SpdyHeadersToHttpResponse( | 322 if (!SpdyHeadersToHttpResponse(response_headers, response_info_)) { |
| 324 response_headers, stream_->GetProtocolVersion(), response_info_)) { | |
| 325 // We do not have complete headers yet. | 323 // We do not have complete headers yet. |
| 326 return RESPONSE_HEADERS_ARE_INCOMPLETE; | 324 return RESPONSE_HEADERS_ARE_INCOMPLETE; |
| 327 } | 325 } |
| 328 | 326 |
| 329 response_info_->response_time = stream_->response_time(); | 327 response_info_->response_time = stream_->response_time(); |
| 330 response_headers_status_ = RESPONSE_HEADERS_ARE_COMPLETE; | 328 response_headers_status_ = RESPONSE_HEADERS_ARE_COMPLETE; |
| 331 // Don't store the SSLInfo in the response here, HttpNetworkTransaction | 329 // Don't store the SSLInfo in the response here, HttpNetworkTransaction |
| 332 // will take care of that part. | 330 // will take care of that part. |
| 333 SSLInfo ssl_info; | 331 SSLInfo ssl_info; |
| 334 NextProto protocol_negotiated = kProtoUnknown; | 332 NextProto protocol_negotiated = kProtoUnknown; |
| 335 stream_->GetSSLInfo(&ssl_info, | 333 stream_->GetSSLInfo(&ssl_info, |
| 336 &response_info_->was_npn_negotiated, | 334 &response_info_->was_npn_negotiated, |
| 337 &protocol_negotiated); | 335 &protocol_negotiated); |
| 338 response_info_->npn_negotiated_protocol = | 336 response_info_->npn_negotiated_protocol = |
| 339 SSLClientSocket::NextProtoToString(protocol_negotiated); | 337 SSLClientSocket::NextProtoToString(protocol_negotiated); |
| 340 response_info_->request_time = stream_->GetRequestTime(); | 338 response_info_->request_time = stream_->GetRequestTime(); |
| 341 response_info_->connection_info = | 339 response_info_->connection_info = |
| 342 HttpResponseInfo::ConnectionInfoFromNextProto(stream_->GetProtocol()); | 340 HttpResponseInfo::ConnectionInfoFromNextProto(kProtoHTTP2); |
| 343 response_info_->vary_data | 341 response_info_->vary_data |
| 344 .Init(*request_info_, *response_info_->headers.get()); | 342 .Init(*request_info_, *response_info_->headers.get()); |
| 345 | 343 |
| 346 if (!response_callback_.is_null()) { | 344 if (!response_callback_.is_null()) { |
| 347 DoResponseCallback(OK); | 345 DoResponseCallback(OK); |
| 348 } | 346 } |
| 349 | 347 |
| 350 return RESPONSE_HEADERS_ARE_COMPLETE; | 348 return RESPONSE_HEADERS_ARE_COMPLETE; |
| 351 } | 349 } |
| 352 | 350 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2; | 604 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2; |
| 607 return; | 605 return; |
| 608 } | 606 } |
| 609 | 607 |
| 610 void SpdyHttpStream::SetPriority(RequestPriority priority) { | 608 void SpdyHttpStream::SetPriority(RequestPriority priority) { |
| 611 // TODO(akalin): Plumb this through to |stream_request_| and | 609 // TODO(akalin): Plumb this through to |stream_request_| and |
| 612 // |stream_|. | 610 // |stream_|. |
| 613 } | 611 } |
| 614 | 612 |
| 615 } // namespace net | 613 } // namespace net |
| OLD | NEW |