[yum-cvs] yum/yum yumRepo.py,1.12,1.13
Jeremy Katz
katzj at linux.duke.edu
Mon Jul 10 17:05:10 UTC 2006
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv14908/yum
Modified Files:
yumRepo.py
Log Message:
>From James Bowes <jbowes at redhat.com>
Attached is a patch that adds an http_headers field to YumRepository
objects. http_headers is a dict (for easy manipulation) that is
converted to a tuple of 2-tuples before it is passed down into urlgrabber.
Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- yumRepo.py 21 Jun 2006 17:07:44 -0000 1.12
+++ yumRepo.py 10 Jul 2006 17:05:08 -0000 1.13
@@ -146,6 +146,7 @@
self._proxy_dict = {}
self.metadata_cookie_fn = 'cachecookie'
self.groups_added = False
+ self.http_headers = {}
# throw in some stubs for things that will be set by the config class
self.basecachedir = ""
@@ -290,6 +291,16 @@
self._proxy_dict['https'] = proxy_string
self._proxy_dict['ftp'] = proxy_string
+ def ___headersListFromDict(self):
+ """Convert our dict of headers to a list of 2-tuples for urlgrabber."""
+ headers = []
+
+ keys = self.http_headers.keys()
+ for key in keys:
+ headers.append((key, self.http_headers[key]))
+
+ return headers
+
def setupGrab(self):
"""sets up the grabber functions with the already stocked in urls for
the mirror groups"""
@@ -299,6 +310,7 @@
else:
mgclass = urlgrabber.mirror.MirrorGroup
+ headers = tuple(self.__headersListFromDict())
self.grabfunc = URLGrabber(keepalive=self.keepalive,
bandwidth=self.bandwidth,
@@ -308,8 +320,10 @@
proxies = self.proxy_dict,
failure_callback=self.failure_obj,
timeout=self.timeout,
+ http_headers=headers,
reget='simple')
+
self.grab = mgclass(self.grabfunc, self.urls,
failure_callback=self.mirror_failure_obj)
@@ -378,10 +392,14 @@
# if url is None do a grab via the mirror group/grab for the repo
# return the path to the local file
- if cache:
- headers = None
- else:
- headers = (('Pragma', 'no-cache'),)
+ # Turn our dict into a list of 2-tuples
+ headers = self.__headersListFromDict()
+
+ # We will always prefer to send no-cache.
+ if not (cache or self.http_headers.has_key('Pragma')):
+ headers.append(('Pragma', 'no-cache'))
+
+ headers = tuple(headers)
if local is None or relative is None:
raise Errors.RepoError, \
More information about the Yum-cvs-commits
mailing list