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) { |
| 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 || |
1561 if (GetResponseHeaders() == nullptr && | 1571 !stream_->GetAlternativeService(&retried_alternative_service_)) { |
1562 stream_->GetAlternativeService(&alternative_service) && | 1572 // If the response headers have already been recieved and passed up |
1563 session_->http_server_properties()->IsAlternativeServiceBroken( | 1573 // then the request can not be retried. Also, if there was no |
1564 alternative_service)) { | 1574 // alternative service used for this request, then there is no |
| 1575 // alternative service to be disabled. |
| 1576 break; |
| 1577 } |
| 1578 if (session_->http_server_properties()->IsAlternativeServiceBroken( |
| 1579 retried_alternative_service_)) { |
| 1580 // If the alternative service was marked as broken while the request |
| 1581 // was in flight, retry the request which will not use the broken |
| 1582 // alternative service. |
| 1583 net_log_.AddEventWithNetErrorCode( |
| 1584 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
| 1585 ResetConnectionAndRequestForResend(); |
| 1586 error = OK; |
| 1587 } else if (session_->params().retry_without_alt_svc_on_quic_errors) { |
| 1588 // Disable alternative services for this request and retry it. If the |
| 1589 // retry succeeds, then the alternative service will be marked as |
| 1590 // broken then. |
| 1591 enable_alternative_services_ = false; |
1565 net_log_.AddEventWithNetErrorCode( | 1592 net_log_.AddEventWithNetErrorCode( |
1566 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1593 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
1567 ResetConnectionAndRequestForResend(); | 1594 ResetConnectionAndRequestForResend(); |
1568 error = OK; | 1595 error = OK; |
1569 } | 1596 } |
1570 break; | 1597 break; |
1571 } | |
1572 case ERR_MISDIRECTED_REQUEST: | 1598 case ERR_MISDIRECTED_REQUEST: |
1573 // If this is the second try, just give up. | 1599 // If this is the second try, just give up. |
1574 if (!enable_ip_based_pooling_ && !enable_alternative_services_) | 1600 if (!enable_ip_based_pooling_ && !enable_alternative_services_) |
1575 return OK; | 1601 return OK; |
1576 // Otherwise retry the request with both IP based pooling | 1602 // Otherwise retry the request with both IP based pooling |
1577 // and Alternative Services disabled. | 1603 // and Alternative Services disabled. |
1578 enable_ip_based_pooling_ = false; | 1604 enable_ip_based_pooling_ = false; |
1579 enable_alternative_services_ = false; | 1605 enable_alternative_services_ = false; |
1580 net_log_.AddEventWithNetErrorCode( | 1606 net_log_.AddEventWithNetErrorCode( |
1581 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); | 1607 NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 continue; | 1808 continue; |
1783 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { | 1809 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { |
1784 FilterSourceStream::ReportContentDecodingFailed(source_type); | 1810 FilterSourceStream::ReportContentDecodingFailed(source_type); |
1785 return false; | 1811 return false; |
1786 } | 1812 } |
1787 } | 1813 } |
1788 return true; | 1814 return true; |
1789 } | 1815 } |
1790 | 1816 |
1791 } // namespace net | 1817 } // namespace net |
OLD | NEW |