/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/HttpServer.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-12-13 16:29:49 UTC
  • mto: (2183.1.1 Aaron's integration)
  • mto: This revision was merged to the branch mainline in revision 2184.
  • Revision ID: v.ladeuil+lp@free.fr-20061213162949-xd0gmdi5uj73l8ya
Thanks again to Aaron, the http server RFC2616 compliance
continue to progress.

* bzrlib/tests/test_http.py:
(TestRanges, TestRanges_urllib, TestRanges_pycurl): New tests
classes for the Range header.

* bzrlib/tests/HttpServer.py:
(TestingHTTPRequestHandler.parse_ranges): RFC2616 says that
'start > end' is a syntax error for a range specifier.
(TestingHTTPRequestHandler.do_GET.check_range): Update
self._satisfiable_ranges, satisfiable_ranges is a free variable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
            # FIXME: RFC2616 says end is optional and default to file_size
106
106
            range_match = self._range_regexp.match(range_str)
107
107
            if range_match is not None:
108
 
                ranges.append((int(range_match.group('start')),
109
 
                               int(range_match.group('end'))))
 
108
                start = int(range_match.group('start'))
 
109
                end = int(range_match.group('end'))
 
110
                if start > end:
 
111
                    # Syntactically invalid range
 
112
                    return 0, []
 
113
                ranges.append((start, end))
110
114
            else:
111
115
                tail_match = self._tail_regexp.match(range_str)
112
116
                if tail_match is not None:
179
183
        if tail != 0:
180
184
            ranges.append((file_size - tail, file_size))
181
185
 
182
 
        satisfiable_ranges = True
 
186
        self._satisfiable_ranges = True
183
187
        if len(ranges) == 0:
184
 
            satisfiable_ranges = False
 
188
            self._satisfiable_ranges = False
185
189
        else:
186
190
            def check_range(range_specifier):
187
191
                start, end = range_specifier
188
 
                # RFC2616 14.35, ranges are invalid if start > end
189
 
                # or start > file_size
190
 
                if start > end or start > file_size:
191
 
                    satisfiable_ranges = False
 
192
                # RFC2616 14.35, ranges are invalid if start >= file_size
 
193
                if start >= file_size:
 
194
                    self._satisfiable_ranges = False # Side-effect !
192
195
                    return 0, 0
193
196
                # RFC2616 14.35, end values should be truncated
194
197
                # to file_size -1 if they exceed it
197
200
 
198
201
            ranges = map(check_range, ranges)
199
202
 
200
 
        if not satisfiable_ranges:
 
203
        if not self._satisfiable_ranges:
201
204
            # RFC2616 14.16 and 14.35 says that when a server
202
205
            # encounters unsatisfiable range specifiers, it
203
206
            # SHOULD return a 416.