Send auth header with GET requests too.

Change-Id: I14d5e5655f5b3137a0ad0d121504993df7f0ed9f
This commit is contained in:
Bill Thiede 2013-08-02 21:07:59 -07:00
parent 38bb307085
commit b899b80ca9
1 changed files with 5 additions and 3 deletions

View File

@ -103,7 +103,7 @@ class CamliOp(object):
self.basepath = ""
if auth:
if len(auth.split(':')) != 2:
# Default to dummy username; current server doesn't care
# Default to dummy username; current server doesn't care
# TODO(jrabbit): care when necessary
auth = "username:" + auth #If username not given use the implicit default, 'username'
self._authorization = ('Basic ' + base64.encodestring(auth).strip())
@ -258,7 +258,8 @@ class CamliOp(object):
new_relative_url = urlparse.urlunparse(pieces)
logging.debug('Redirect %s -> %s', relative_url, new_relative_url)
relative_url = new_relative_url
self.connection.request('GET', relative_url)
self.connection.request('GET', relative_url, headers={
'Authorization': self._authorization})
response = self.connection.getresponse()
if response.status != 200:
@ -353,7 +354,8 @@ class CamliOp(object):
fullpath = self.basepath + '/camli/'
else:
fullpath = '/camli/'
self.connection.request('GET', fullpath + blobref)
self.connection.request('GET', fullpath + blobref,
headers={'Authorization': self._authorization})
response = self.connection.getresponse()
if response.status == 404:
logging.debug('Server does not have blobref=%s', blobref)