~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-28 07:08:27 UTC
  • mfrom: (2553.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070628070827-h5s313dg5tnag9vj
(robertc) Show the names of commit hooks during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
        self.wfile.write(out_buffer.getvalue())
151
151
 
152
152
 
153
 
class LimitedRangeRequestHandler(TestingHTTPRequestHandler):
154
 
    """Errors out when range specifiers exceed the limit"""
155
 
 
156
 
    def get_multiple_ranges(self, file, file_size, ranges):
157
 
        """Refuses the multiple ranges request"""
158
 
        tcs = self.server.test_case_server
159
 
        if tcs.range_limit is not None and len(ranges) > tcs.range_limit:
160
 
            file.close()
161
 
            # Emulate apache behavior
162
 
            self.send_error(400, "Bad Request")
163
 
            return
164
 
        return TestingHTTPRequestHandler.get_multiple_ranges(self, file,
165
 
                                                             file_size, ranges)
166
 
 
167
 
    def do_GET(self):
168
 
        tcs = self.server.test_case_server
169
 
        tcs.GET_request_nb += 1
170
 
        return TestingHTTPRequestHandler.do_GET(self)
171
 
 
172
 
 
173
 
class LimitedRangeHTTPServer(HttpServer):
174
 
    """An HttpServer erroring out on requests with too much range specifiers"""
175
 
 
176
 
    def __init__(self, request_handler=LimitedRangeRequestHandler,
177
 
                 range_limit=None):
178
 
        HttpServer.__init__(self, request_handler)
179
 
        self.range_limit = range_limit
180
 
        self.GET_request_nb = 0
181
 
 
182
 
 
183
153
class SingleRangeRequestHandler(TestingHTTPRequestHandler):
184
154
    """Always reply to range request as if they were single.
185
155
 
367
337
            self.end_headers()
368
338
            return
369
339
 
 
340
        TestingHTTPRequestHandler.do_GET(self)
 
341
 
370
342
 
371
343
class BasicAuthRequestHandler(AuthRequestHandler):
372
344
    """Implements the basic authentication of a request"""