Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: net/tools/testserver/testserver.py

Issue 10909251: Remove Python < 2.6 compatibility imports from testserver.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index ff684a8afaa888865c68ebabb0c4f0538bb62de9..aeb0575118b6761feb3069ff64c8e5f4838f2974 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -18,7 +18,9 @@ import base64
import BaseHTTPServer
import cgi
import errno
+import hashlib
import httplib
+import json
import minica
import optparse
import os
@@ -44,18 +46,6 @@ import pyftpdlib.ftpserver
import tlslite
import tlslite.api
-try:
- import hashlib
- _new_md5 = hashlib.md5
-except ImportError:
- import md5
- _new_md5 = md5.new
-
-try:
- import json
-except ImportError:
- import simplejson as json
-
if sys.platform == 'win32':
import msvcrt
@@ -1318,7 +1308,7 @@ class TestPageHandler(BasePageHandler):
"""
if force_reset or not self.server.nonce_time:
self.server.nonce_time = time.time()
- return _new_md5('privatekey%s%d' %
+ return hashlib.md5('privatekey%s%d' %
(self.path, self.server.nonce_time)).hexdigest()
def AuthDigestHandler(self):
@@ -1333,7 +1323,7 @@ class TestPageHandler(BasePageHandler):
stale = 'stale' in self.path
nonce = self.GetNonce(force_reset=stale)
- opaque = _new_md5('opaque').hexdigest()
+ opaque = hashlib.md5('opaque').hexdigest()
password = 'secret'
realm = 'testrealm'
@@ -1355,14 +1345,14 @@ class TestPageHandler(BasePageHandler):
# Check the 'response' value and make sure it matches our magic hash.
# See http://www.ietf.org/rfc/rfc2617.txt
- hash_a1 = _new_md5(
+ hash_a1 = hashlib.md5(
':'.join([pairs['username'], realm, password])).hexdigest()
- hash_a2 = _new_md5(':'.join([self.command, pairs['uri']])).hexdigest()
+ hash_a2 = hashlib.md5(':'.join([self.command, pairs['uri']])).hexdigest()
if 'qop' in pairs and 'nc' in pairs and 'cnonce' in pairs:
- response = _new_md5(':'.join([hash_a1, nonce, pairs['nc'],
+ response = hashlib.md5(':'.join([hash_a1, nonce, pairs['nc'],
pairs['cnonce'], pairs['qop'], hash_a2])).hexdigest()
else:
- response = _new_md5(':'.join([hash_a1, nonce, hash_a2])).hexdigest()
+ response = hashlib.md5(':'.join([hash_a1, nonce, hash_a2])).hexdigest()
if pairs['response'] != response:
raise Exception('wrong password')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698