| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
| 6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
| 7 | 7 |
| 8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 855 |
| 856 LOG(INFO) << "The proxy " << auth_origin << " requested auth"; | 856 LOG(INFO) << "The proxy " << auth_origin << " requested auth"; |
| 857 | 857 |
| 858 // The auth we tried just failed, hence it can't be valid. | 858 // The auth we tried just failed, hence it can't be valid. |
| 859 // Remove it from the cache so it won't be used again. | 859 // Remove it from the cache so it won't be used again. |
| 860 if (auth_handler_.get() && !auth_identity_.invalid && | 860 if (auth_handler_.get() && !auth_identity_.invalid && |
| 861 auth_handler_->IsFinalRound()) { | 861 auth_handler_->IsFinalRound()) { |
| 862 if (auth_identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP) | 862 if (auth_identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP) |
| 863 auth_cache_.Remove(auth_origin, | 863 auth_cache_.Remove(auth_origin, |
| 864 auth_handler_->realm(), | 864 auth_handler_->realm(), |
| 865 auth_handler_->scheme(), |
| 865 auth_identity_.username, | 866 auth_identity_.username, |
| 866 auth_identity_.password); | 867 auth_identity_.password); |
| 867 auth_handler_ = NULL; | 868 auth_handler_ = NULL; |
| 868 auth_identity_ = HttpAuth::Identity(); | 869 auth_identity_ = HttpAuth::Identity(); |
| 869 } | 870 } |
| 870 | 871 |
| 871 auth_identity_.invalid = true; | 872 auth_identity_.invalid = true; |
| 872 HttpAuth::ChooseBestChallenge(http_auth_handler_factory_, headers, | 873 HttpAuth::ChooseBestChallenge(http_auth_handler_factory_, headers, |
| 873 HttpAuth::AUTH_PROXY, | 874 HttpAuth::AUTH_PROXY, |
| 874 auth_origin, &auth_handler_); | 875 auth_origin, &auth_handler_); |
| 875 if (!auth_handler_) { | 876 if (!auth_handler_) { |
| 876 LOG(ERROR) << "Can't perform auth to the proxy " << auth_origin; | 877 LOG(ERROR) << "Can't perform auth to the proxy " << auth_origin; |
| 877 return ERR_TUNNEL_CONNECTION_FAILED; | 878 return ERR_TUNNEL_CONNECTION_FAILED; |
| 878 } | 879 } |
| 879 if (auth_handler_->NeedsIdentity()) { | 880 if (auth_handler_->NeedsIdentity()) { |
| 880 HttpAuthCache::Entry* entry = auth_cache_.LookupByRealm( | 881 // We only support basic authentication scheme now. |
| 881 auth_origin, auth_handler_->realm()); | 882 // TODO(ukai): Support other authentication scheme. |
| 883 HttpAuthCache::Entry* entry = |
| 884 auth_cache_.Lookup(auth_origin, auth_handler_->realm(), "basic"); |
| 882 if (entry) { | 885 if (entry) { |
| 883 if (entry->handler()->scheme() != "basic") { | |
| 884 // We only support basic authentication scheme now. | |
| 885 // TODO(ukai): Support other authentication scheme. | |
| 886 return ERR_TUNNEL_CONNECTION_FAILED; | |
| 887 } | |
| 888 auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; | 886 auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; |
| 889 auth_identity_.invalid = false; | 887 auth_identity_.invalid = false; |
| 890 auth_identity_.username = entry->username(); | 888 auth_identity_.username = entry->username(); |
| 891 auth_identity_.password = entry->password(); | 889 auth_identity_.password = entry->password(); |
| 892 // Restart with auth info. | 890 // Restart with auth info. |
| 893 } | 891 } |
| 894 return ERR_PROXY_AUTH_REQUESTED; | 892 return ERR_PROXY_AUTH_REQUESTED; |
| 895 } else { | 893 } else { |
| 896 auth_identity_.invalid = false; | 894 auth_identity_.invalid = false; |
| 897 } | 895 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 939 |
| 942 SSLConfigService* SocketStream::ssl_config_service() const { | 940 SSLConfigService* SocketStream::ssl_config_service() const { |
| 943 return context_->ssl_config_service(); | 941 return context_->ssl_config_service(); |
| 944 } | 942 } |
| 945 | 943 |
| 946 ProxyService* SocketStream::proxy_service() const { | 944 ProxyService* SocketStream::proxy_service() const { |
| 947 return context_->proxy_service(); | 945 return context_->proxy_service(); |
| 948 } | 946 } |
| 949 | 947 |
| 950 } // namespace net | 948 } // namespace net |
| OLD | NEW |