Commits

jaraco  committed 6c851ba

Bumped to 1.2

  • Participants
  • Parent commits 8035fbd

Comments (0)

Files changed (2)

File jaraco/net/http.py

 def get_url(url, dest=None, replace_newer=False, touch_older=True):
 	src = urllib2.urlopen(url)
 	log.debug(src.headers)
-	mod_time = datetime.datetime.strptime(src.headers['last-modified'], '%a, %d %b %Y %H:%M:%S %Z')
+	if 'last-modified' in src.headers:
+		mod_time = datetime.datetime.strptime(src.headers['last-modified'], '%a, %d %b %Y %H:%M:%S %Z')
+	else:
+		mod_time = None
 	content_length = int(src.headers['content-length'])
 	fname = dest or get_content_disposition_filename(src) or get_url_filename(url) or 'result.dat'
-	if os.path.exists(fname):
+	if mod_time and os.path.exists(fname):
 		stat = os.lstat(fname)
 		previous_size = stat.st_size
 		previous_mod_time = datetime.datetime.utcfromtimestamp(stat.st_mtime)
 	for line in src:
 		dest.write(line)
 	dest.close()
-	set_time(fname, mod_time)
+	if mod_time:
+		set_time(fname, mod_time)
 
 try:
 	from jaraco.filesystem import set_time
 
 setup(
 	name = 'jaraco.net',
-	version = '1.1',
+	version = '1.2',
 	description = 'Networking tools by jaraco',
 	long_description = long_description,
 	author = 'Jason R. Coombs',