##// END OF EJS Templates
Minor hgweb fixup for new diff code...
Minor hgweb fixup for new diff code -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Minor hgweb fixup for new diff code manifest hash: a80a817fa1511c6ea76f07b2e03691539c19de55 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxO7lywK+sNU5EO8RArAkAJ49Piw1lKwhno5XtTdE0J2B3KIeJQCgpeZW JbFuy/zzo2e45xu6Uez8CMw= =sQOB -----END PGP SIGNATURE-----

File last commit:

r372:4b0f562c default
r539:44b29b98 default
Show More
httprangereader.py
24 lines | 762 B | text/x-python | PythonLexer
# httprangereader.py - just what it says
#
# Copyright 2005 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
import byterange, urllib2
class httprangereader:
def __init__(self, url):
self.url = url
self.pos = 0
def seek(self, pos):
self.pos = pos
def read(self, bytes=None):
opener = urllib2.build_opener(byterange.HTTPRangeHandler())
urllib2.install_opener(opener)
req = urllib2.Request(self.url)
end = ''
if bytes: end = self.pos + bytes
req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
f = urllib2.urlopen(req)
return f.read()