| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/web/public/test/http_server/http_auth_response_provider.h" | 5 #import "ios/web/public/test/http_server/http_auth_response_provider.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "net/http/http_request_headers.h" | 9 #include "net/http/http_request_headers.h" |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 12 namespace web { | 16 namespace web { |
| 13 | 17 |
| 14 HttpAuthResponseProvider::HttpAuthResponseProvider(const GURL& url, | 18 HttpAuthResponseProvider::HttpAuthResponseProvider(const GURL& url, |
| 15 const std::string& realm, | 19 const std::string& realm, |
| 16 const std::string& username, | 20 const std::string& username, |
| 17 const std::string& password) | 21 const std::string& password) |
| 18 : url_(url), realm_(realm), username_(username), password_(password) {} | 22 : url_(url), realm_(realm), username_(username), password_(password) {} |
| 19 | 23 |
| 20 HttpAuthResponseProvider::~HttpAuthResponseProvider() = default; | 24 HttpAuthResponseProvider::~HttpAuthResponseProvider() = default; |
| 21 | 25 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 std::string auth = | 48 std::string auth = |
| 45 base::StringPrintf("%s:%s", username_.c_str(), password_.c_str()); | 49 base::StringPrintf("%s:%s", username_.c_str(), password_.c_str()); |
| 46 std::string encoded_auth; | 50 std::string encoded_auth; |
| 47 base::Base64Encode(auth, &encoded_auth); | 51 base::Base64Encode(auth, &encoded_auth); |
| 48 return header == base::StringPrintf("Basic %s", encoded_auth.c_str()); | 52 return header == base::StringPrintf("Basic %s", encoded_auth.c_str()); |
| 49 } | 53 } |
| 50 return false; | 54 return false; |
| 51 } | 55 } |
| 52 | 56 |
| 53 } // namespace web | 57 } // namespace web |
| OLD | NEW |