Ñò
ñG“Ic @ s0 d e f d „ ƒ YZ d e f d „ ƒ YZ d S( t Rangec B s° e Z d Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e
e ƒ Z d „ Z e e ƒ Z d „ Z
e e
ƒ Z
d d
„ Z e e ƒ Z d „ Z e e ƒ Z RS(
sì
Represents the Range header.
This only represents ``bytes`` ranges, which are the only kind
specified in HTTP. This can represent multiple sets of ranges,
but no place else is this multi-range facility supported.
c C s$ x | D] \ } } q W| | _ d S( N( t ranges( t selfR t begint end( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt __init__ s c C s= x6 | i D]+ \ } } | d j o | | j o t Sq
Wt S( sq
Returns true if this range can be satisfied by the resource
with the given byte length.
N( R t Nonet Falset True( R t lengthR R ( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt satisfiable s
c C st t | i ƒ d j o d S| i d \ } } | d j o | d j o | | f Sd S| | j o d S| | f S( sÎ
*If* there is only one range, and *if* it is satisfiable by
the given length, then return a (begin, end) non-inclusive range
of bytes to serve. Otherwise return None
If length is None (unknown length), then the resulting range
may be (begin, None), meaning it should be served from that
point. If it's a range with a fixed endpoint we won't know if
it is satisfiable, so this will return None.
i i N( t lenR R ( R R R R ( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt range_for_length s
c C s9 | i | ƒ } | d j o d St | d | d | ƒ S( s
Works like range_for_length; returns None or a ContentRange object
You can use it like::
response.content_range = req.range.content_range(response.content_length)
Though it's still up to you to actually serve that content range!
i i N( R R t ContentRange( R R t range( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt
content_range2 s
c C s | i d | i | i ƒ ƒ S( Nt bytes( t serialize_bytest python_ranges_to_bytesR ( R ( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt __str__A s c C s) d | i i d i t t | i ƒ ƒ f S( Ns <%s ranges=%s>s , ( t __class__t __name__t joint mapt reprR ( R ( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt __repr__D s c C sp | i | ƒ } | d j o d S| \ } } | i ƒ d j o d S| i | ƒ } | d j o d S| | ƒ S( sH
Parse the header; may return None if header is invalid
R N( t parse_bytesR t lowert bytes_to_python_ranges( t clst headerR t unitsR ( ( s3 /usr/lib/python2.6/site-packages/webob/byterange.pyt parseJ s
c C s³ | p t d ƒ ‚ n g } d } yh| i d d ƒ \ } } | i ƒ i ƒ } x7| i d ƒ D]&} d | j o
t ƒ ‚ n | i d ƒ o9 | d j o t d ƒ ‚ n t | ƒ } d } d } n« | i d d ƒ \ } } t | ƒ } | | j p
| d j o | G| GHt d ƒ ‚ n | i ƒ p
d } n
t | ƒ } | d j o | | j o t d
ƒ ‚ n | } | i | | f ƒ q` WWn t j
o } | GHd SX| | f S( sÛ
Parse a Range header into (bytes, list_of_ranges). Note that the
ranges are *inclusive* (like in HTTP, not like in Python
typically).
Will return None if the header is invalid
s The header must not be emptyi t =i t ,t -s too many end rangesiÿÿÿÿs begin