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 and Alternative Services are disabled under the same | 854 // IP based pooling is only enabled on a retry after 421 Misdirected Request |
855 // circumstances: on a retry after 421 Misdirected Request is received. | 855 // is received. Alternative Services are also disabled in this case (though |
856 DCHECK(enable_ip_based_pooling_ == enable_alternative_services_); | 856 // they can also be disabled when retrying after a QUIC error). |
857 if (!enable_ip_based_pooling_) | |
858 DCHECK(!enable_alternative_services_); | |
857 if (ForWebSocketHandshake()) { | 859 if (ForWebSocketHandshake()) { |
858 stream_request_.reset( | 860 stream_request_.reset( |
859 session_->http_stream_factory_for_websocket() | 861 session_->http_stream_factory_for_websocket() |
860 ->RequestWebSocketHandshakeStream( | 862 ->RequestWebSocketHandshakeStream( |
861 *request_, priority_, server_ssl_config_, proxy_ssl_config_, | 863 *request_, priority_, server_ssl_config_, proxy_ssl_config_, |
862 this, websocket_handshake_stream_base_create_helper_, | 864 this, websocket_handshake_stream_base_create_helper_, |
863 enable_ip_based_pooling_, enable_alternative_services_, | 865 enable_ip_based_pooling_, enable_alternative_services_, |
864 net_log_)); | 866 net_log_)); |
865 } else { | 867 } else { |
866 stream_request_.reset(session_->http_stream_factory()->RequestStream( | 868 stream_request_.reset(session_->http_stream_factory()->RequestStream( |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1349 stream_->IsResponseBodyComplete() && stream_->CanReuseConnection(); | 1351 stream_->IsResponseBodyComplete() && stream_->CanReuseConnection(); |
1350 | 1352 |
1351 stream_->Close(!keep_alive); | 1353 stream_->Close(!keep_alive); |
1352 // Note: we don't reset the stream here. We've closed it, but we still | 1354 // Note: we don't reset the stream here. We've closed it, but we still |
1353 // need it around so that callers can call methods such as | 1355 // need it around so that callers can call methods such as |
1354 // GetUploadProgress() and have them be meaningful. | 1356 // GetUploadProgress() and have them be meaningful. |
1355 // TODO(mbelshe): This means we closed the stream here, and we close it | 1357 // TODO(mbelshe): This means we closed the stream here, and we close it |
1356 // again in ~HttpNetworkTransaction. Clean that up. | 1358 // again in ~HttpNetworkTransaction. Clean that up. |
1357 | 1359 |
1358 // The next Read call will return 0 (EOF). | 1360 // 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) { | |
ianswett
2017/04/13 14:02:45
To clarify, does this break any alt-svc, not just
Ryan Hamilton
2017/04/13 17:26:56
Yes, this code here is not QUIC specific so it wou
| |
1366 session_->http_server_properties()->MarkAlternativeServiceBroken( | |
1367 retried_alternative_service_); | |
1368 } | |
1359 } | 1369 } |
1360 | 1370 |
1361 // Clear these to avoid leaving around old state. | 1371 // Clear these to avoid leaving around old state. |
1362 read_buf_ = NULL; | 1372 read_buf_ = NULL; |
1363 read_buf_len_ = 0; | 1373 read_buf_len_ = 0; |
1364 | 1374 |
1365 return result; | 1375 return result; |
1366 } | 1376 } |
1367 | 1377 |
1368 int HttpNetworkTransaction::DoDrainBodyForAuthRestart() { | 1378 int HttpNetworkTransaction::DoDrainBodyForAuthRestart() { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 } | 1559 } |
1550 break; | 1560 break; |
1551 case ERR_SPDY_PING_FAILED: | 1561 case ERR_SPDY_PING_FAILED: |
1552 case ERR_SPDY_SERVER_REFUSED_STREAM: | 1562 case ERR_SPDY_SERVER_REFUSED_STREAM: |
1553 case ERR_QUIC_HANDSHAKE_FAILED: | 1563 case ERR_QUIC_HANDSHAKE_FAILED: |
1554 net_log_.AddEventWithNetErrorCode( | 1564 net_log_.AddEventWithNetErrorCode( |
1555 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1565 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
1556 ResetConnectionAndRequestForResend(); | 1566 ResetConnectionAndRequestForResend(); |
1557 error = OK; | 1567 error = OK; |
1558 break; | 1568 break; |
1559 case ERR_QUIC_PROTOCOL_ERROR: { | 1569 case ERR_QUIC_PROTOCOL_ERROR: |
1560 AlternativeService alternative_service; | 1570 if (GetResponseHeaders() != nullptr || |
ianswett
2017/04/13 14:02:45
Can you add some comments here? I believe I under
Ryan Hamilton
2017/04/13 17:26:56
Done.
| |
1561 if (GetResponseHeaders() == nullptr && | 1571 !stream_->GetAlternativeService(&retried_alternative_service_)) { |
1562 stream_->GetAlternativeService(&alternative_service) && | 1572 break; |
1563 session_->http_server_properties()->IsAlternativeServiceBroken( | 1573 } |
1564 alternative_service)) { | 1574 if (session_->http_server_properties()->IsAlternativeServiceBroken( |
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; | |
1565 net_log_.AddEventWithNetErrorCode( | 1582 net_log_.AddEventWithNetErrorCode( |
1566 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1583 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
1567 ResetConnectionAndRequestForResend(); | 1584 ResetConnectionAndRequestForResend(); |
1568 error = OK; | 1585 error = OK; |
1569 } | 1586 } |
1570 break; | 1587 break; |
1571 } | |
1572 case ERR_MISDIRECTED_REQUEST: | 1588 case ERR_MISDIRECTED_REQUEST: |
1573 // If this is the second try, just give up. | 1589 // If this is the second try, just give up. |
1574 if (!enable_ip_based_pooling_ && !enable_alternative_services_) | 1590 if (!enable_ip_based_pooling_ && !enable_alternative_services_) |
1575 return OK; | 1591 return OK; |
1576 // Otherwise retry the request with both IP based pooling | 1592 // Otherwise retry the request with both IP based pooling |
1577 // and Alternative Services disabled. | 1593 // and Alternative Services disabled. |
1578 enable_ip_based_pooling_ = false; | 1594 enable_ip_based_pooling_ = false; |
1579 enable_alternative_services_ = false; | 1595 enable_alternative_services_ = false; |
1580 net_log_.AddEventWithNetErrorCode( | 1596 net_log_.AddEventWithNetErrorCode( |
1581 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1597 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 continue; | 1798 continue; |
1783 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { | 1799 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { |
1784 FilterSourceStream::ReportContentDecodingFailed(source_type); | 1800 FilterSourceStream::ReportContentDecodingFailed(source_type); |
1785 return false; | 1801 return false; |
1786 } | 1802 } |
1787 } | 1803 } |
1788 return true; | 1804 return true; |
1789 } | 1805 } |
1790 | 1806 |
1791 } // namespace net | 1807 } // namespace net |
OLD | NEW |