OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_auth_handler_digest.h" | 5 #include "net/http/http_auth_handler_digest.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
18 #include "net/http/http_auth.h" | 18 #include "net/http/http_auth.h" |
19 #include "net/http/http_request_info.h" | 19 #include "net/http/http_request_info.h" |
20 #include "net/http/http_util.h" | 20 #include "net/http/http_util.h" |
21 #include "url/gurl.h" | |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 // Digest authentication is specified in RFC 2617. | 25 // Digest authentication is specified in RFC 2617. |
25 // The expanded derivations are listed in the tables below. | 26 // The expanded derivations are listed in the tables below. |
26 | 27 |
27 //==========+==========+==========================================+ | 28 //==========+==========+==========================================+ |
28 // qop |algorithm | response | | 29 // qop |algorithm | response | |
29 //==========+==========+==========================================+ | 30 //==========+==========+==========================================+ |
30 // ? | ?, md5, | MD5(MD5(A1):nonce:MD5(A2)) | | 31 // ? | ?, md5, | MD5(MD5(A1):nonce:MD5(A2)) | |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 | 298 |
298 void HttpAuthHandlerDigest::GetRequestMethodAndPath( | 299 void HttpAuthHandlerDigest::GetRequestMethodAndPath( |
299 const HttpRequestInfo* request, | 300 const HttpRequestInfo* request, |
300 std::string* method, | 301 std::string* method, |
301 std::string* path) const { | 302 std::string* path) const { |
302 DCHECK(request); | 303 DCHECK(request); |
303 | 304 |
304 const GURL& url = request->url; | 305 const GURL& url = request->url; |
305 | 306 |
306 if (target_ == HttpAuth::AUTH_PROXY && | 307 if (target_ == HttpAuth::AUTH_PROXY && |
307 (url.SchemeIs("https") || url.SchemeIs("ws") || url.SchemeIs("wss"))) { | 308 (url.SchemeIs("https") || url.SchemeIsWSOrWSS())) { |
szym
2013/11/19 04:39:12
Double checking: is "ws" okay here? ("http" is not
tyoshino (SeeGerritForStatus)
2013/11/19 04:53:47
WebSockets use CONNECT method for both non-secure
| |
308 *method = "CONNECT"; | 309 *method = "CONNECT"; |
309 *path = GetHostAndPort(url); | 310 *path = GetHostAndPort(url); |
310 } else { | 311 } else { |
311 *method = request->method; | 312 *method = request->method; |
312 *path = HttpUtil::PathForRequest(url); | 313 *path = HttpUtil::PathForRequest(url); |
313 } | 314 } |
314 } | 315 } |
315 | 316 |
316 std::string HttpAuthHandlerDigest::AssembleResponseDigest( | 317 std::string HttpAuthHandlerDigest::AssembleResponseDigest( |
317 const std::string& method, | 318 const std::string& method, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 // TODO(eroman): Supposedly IIS server requires quotes surrounding qop. | 373 // TODO(eroman): Supposedly IIS server requires quotes surrounding qop. |
373 authorization += ", qop=" + QopToString(qop_); | 374 authorization += ", qop=" + QopToString(qop_); |
374 authorization += ", nc=" + nc; | 375 authorization += ", nc=" + nc; |
375 authorization += ", cnonce=" + HttpUtil::Quote(cnonce); | 376 authorization += ", cnonce=" + HttpUtil::Quote(cnonce); |
376 } | 377 } |
377 | 378 |
378 return authorization; | 379 return authorization; |
379 } | 380 } |
380 | 381 |
381 } // namespace net | 382 } // namespace net |
OLD | NEW |