[PATCH] send http auth information pre-emptively to reduce roundtrips
Sune Foldager
cryo at cyanite.org
Sun Apr 5 20:19:57 UTC 2009
This patch cause hg to send http auth information along on the first
request instead of waiting for the remote server to respond with a
challenge. The RFC specifically allows this, and it seems silly to not
send auth information when the user actually specified it in the url (or
via configuration). More network roundtrips. urllib2 doesn't seem to
have an option to do this :-(.
--
Sune Foldager.
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1238961972 -7200
# Node ID 67bcd654e41c94913496772c5c716cab96a5557b
# Parent 5f4f6c45ea85b0cfaef47cfca9b4cf679cd9fc52
send http auth information pre-emptively to reduce roundtrips
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -7,7 +7,7 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
-import urllib, urllib2, urlparse, httplib, os, re
+import urllib, urllib2, urlparse, httplib, os, re, base64
from i18n import _
import keepalive, util
@@ -313,6 +313,11 @@
# 1.0 here is the _protocol_ version
opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
+
+ # pre-emptively send auth header to reduce roundtrips
+ if authinfo:
+ opener.addheaders.append(('Authorization', 'Basic ' +
+ base64.b64encode(user + ':' + passwd)))
return opener
scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://')
More information about the Mercurial-devel
mailing list