| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 844 |
| 845 int HttpNetworkTransaction::DoCreateStream() { | 845 int HttpNetworkTransaction::DoCreateStream() { |
| 846 // TODO(mmenke): Remove ScopedTracker below once crbug.com/424359 is fixed. | 846 // TODO(mmenke): Remove ScopedTracker below once crbug.com/424359 is fixed. |
| 847 tracked_objects::ScopedTracker tracking_profile( | 847 tracked_objects::ScopedTracker tracking_profile( |
| 848 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 848 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 849 "424359 HttpNetworkTransaction::DoCreateStream")); | 849 "424359 HttpNetworkTransaction::DoCreateStream")); |
| 850 | 850 |
| 851 response_.network_accessed = true; | 851 response_.network_accessed = true; |
| 852 | 852 |
| 853 next_state_ = STATE_CREATE_STREAM_COMPLETE; | 853 next_state_ = STATE_CREATE_STREAM_COMPLETE; |
| 854 // IP based pooling is only enabled on a retry after 421 Misdirected Request | 854 // IP based pooling and Alternative Services are disabled under the same |
| 855 // is received. Alternative Services are also disabled in this case (though | 855 // circumstances: on a retry after 421 Misdirected Request is received. |
| 856 // they can also be disabled when retrying after a QUIC error). | 856 DCHECK(enable_ip_based_pooling_ == enable_alternative_services_); |
| 857 if (!enable_ip_based_pooling_) | |
| 858 DCHECK(!enable_alternative_services_); | |
| 859 if (ForWebSocketHandshake()) { | 857 if (ForWebSocketHandshake()) { |
| 860 stream_request_.reset( | 858 stream_request_.reset( |
| 861 session_->http_stream_factory_for_websocket() | 859 session_->http_stream_factory_for_websocket() |
| 862 ->RequestWebSocketHandshakeStream( | 860 ->RequestWebSocketHandshakeStream( |
| 863 *request_, priority_, server_ssl_config_, proxy_ssl_config_, | 861 *request_, priority_, server_ssl_config_, proxy_ssl_config_, |
| 864 this, websocket_handshake_stream_base_create_helper_, | 862 this, websocket_handshake_stream_base_create_helper_, |
| 865 enable_ip_based_pooling_, enable_alternative_services_, | 863 enable_ip_based_pooling_, enable_alternative_services_, |
| 866 net_log_)); | 864 net_log_)); |
| 867 } else { | 865 } else { |
| 868 stream_request_.reset(session_->http_stream_factory()->RequestStream( | 866 stream_request_.reset(session_->http_stream_factory()->RequestStream( |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 stream_->IsResponseBodyComplete() && stream_->CanReuseConnection(); | 1349 stream_->IsResponseBodyComplete() && stream_->CanReuseConnection(); |
| 1352 | 1350 |
| 1353 stream_->Close(!keep_alive); | 1351 stream_->Close(!keep_alive); |
| 1354 // Note: we don't reset the stream here. We've closed it, but we still | 1352 // Note: we don't reset the stream here. We've closed it, but we still |
| 1355 // need it around so that callers can call methods such as | 1353 // need it around so that callers can call methods such as |
| 1356 // GetUploadProgress() and have them be meaningful. | 1354 // GetUploadProgress() and have them be meaningful. |
| 1357 // TODO(mbelshe): This means we closed the stream here, and we close it | 1355 // TODO(mbelshe): This means we closed the stream here, and we close it |
| 1358 // again in ~HttpNetworkTransaction. Clean that up. | 1356 // again in ~HttpNetworkTransaction. Clean that up. |
| 1359 | 1357 |
| 1360 // The next Read call will return 0 (EOF). | 1358 // The next Read call will return 0 (EOF). |
| 1361 | |
| 1362 // This transaction was successful. If it had been retried because of an | |
| 1363 // error with an alternative service, mark that alternative service broken. | |
| 1364 if (!enable_alternative_services_ && | |
| 1365 retried_alternative_service_.protocol != kProtoUnknown) { | |
| 1366 session_->http_server_properties()->MarkAlternativeServiceBroken( | |
| 1367 retried_alternative_service_); | |
| 1368 } | |
| 1369 } | 1359 } |
| 1370 | 1360 |
| 1371 // Clear these to avoid leaving around old state. | 1361 // Clear these to avoid leaving around old state. |
| 1372 read_buf_ = NULL; | 1362 read_buf_ = NULL; |
| 1373 read_buf_len_ = 0; | 1363 read_buf_len_ = 0; |
| 1374 | 1364 |
| 1375 return result; | 1365 return result; |
| 1376 } | 1366 } |
| 1377 | 1367 |
| 1378 int HttpNetworkTransaction::DoDrainBodyForAuthRestart() { | 1368 int HttpNetworkTransaction::DoDrainBodyForAuthRestart() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 } | 1549 } |
| 1560 break; | 1550 break; |
| 1561 case ERR_SPDY_PING_FAILED: | 1551 case ERR_SPDY_PING_FAILED: |
| 1562 case ERR_SPDY_SERVER_REFUSED_STREAM: | 1552 case ERR_SPDY_SERVER_REFUSED_STREAM: |
| 1563 case ERR_QUIC_HANDSHAKE_FAILED: | 1553 case ERR_QUIC_HANDSHAKE_FAILED: |
| 1564 net_log_.AddEventWithNetErrorCode( | 1554 net_log_.AddEventWithNetErrorCode( |
| 1565 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1555 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
| 1566 ResetConnectionAndRequestForResend(); | 1556 ResetConnectionAndRequestForResend(); |
| 1567 error = OK; | 1557 error = OK; |
| 1568 break; | 1558 break; |
| 1569 case ERR_QUIC_PROTOCOL_ERROR: | 1559 case ERR_QUIC_PROTOCOL_ERROR: { |
| 1570 if (GetResponseHeaders() != nullptr || | 1560 AlternativeService alternative_service; |
| 1571 !stream_->GetAlternativeService(&retried_alternative_service_)) { | 1561 if (GetResponseHeaders() == nullptr && |
| 1572 break; | 1562 stream_->GetAlternativeService(&alternative_service) && |
| 1573 } | 1563 session_->http_server_properties()->IsAlternativeServiceBroken( |
| 1574 if (session_->http_server_properties()->IsAlternativeServiceBroken( | 1564 alternative_service)) { |
| 1575 retried_alternative_service_)) { | |
| 1576 net_log_.AddEventWithNetErrorCode( | |
| 1577 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | |
| 1578 ResetConnectionAndRequestForResend(); | |
| 1579 error = OK; | |
| 1580 } else if (session_->params().retry_without_alt_svc_on_quic_errors) { | |
| 1581 enable_alternative_services_ = false; | |
| 1582 net_log_.AddEventWithNetErrorCode( | 1565 net_log_.AddEventWithNetErrorCode( |
| 1583 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1566 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
| 1584 ResetConnectionAndRequestForResend(); | 1567 ResetConnectionAndRequestForResend(); |
| 1585 error = OK; | 1568 error = OK; |
| 1586 } | 1569 } |
| 1587 break; | 1570 break; |
| 1571 } |
| 1588 case ERR_MISDIRECTED_REQUEST: | 1572 case ERR_MISDIRECTED_REQUEST: |
| 1589 // If this is the second try, just give up. | 1573 // If this is the second try, just give up. |
| 1590 if (!enable_ip_based_pooling_ && !enable_alternative_services_) | 1574 if (!enable_ip_based_pooling_ && !enable_alternative_services_) |
| 1591 return OK; | 1575 return OK; |
| 1592 // Otherwise retry the request with both IP based pooling | 1576 // Otherwise retry the request with both IP based pooling |
| 1593 // and Alternative Services disabled. | 1577 // and Alternative Services disabled. |
| 1594 enable_ip_based_pooling_ = false; | 1578 enable_ip_based_pooling_ = false; |
| 1595 enable_alternative_services_ = false; | 1579 enable_alternative_services_ = false; |
| 1596 net_log_.AddEventWithNetErrorCode( | 1580 net_log_.AddEventWithNetErrorCode( |
| 1597 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1581 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 continue; | 1782 continue; |
| 1799 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { | 1783 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { |
| 1800 FilterSourceStream::ReportContentDecodingFailed(source_type); | 1784 FilterSourceStream::ReportContentDecodingFailed(source_type); |
| 1801 return false; | 1785 return false; |
| 1802 } | 1786 } |
| 1803 } | 1787 } |
| 1804 return true; | 1788 return true; |
| 1805 } | 1789 } |
| 1806 | 1790 |
| 1807 } // namespace net | 1791 } // namespace net |
| OLD | NEW |