~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HttpServer.py

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    def handle_one_request(self):
61
61
        """Handle a single HTTP request.
62
62
 
 
63
        We catch all socket errors occurring when the client close the
 
64
        connection early to avoid polluting the test results.
 
65
        """
 
66
        try:
 
67
            self._handle_one_request()
 
68
        except socket.error, e:
 
69
            if (len(e.args) > 0
 
70
                and e.args[0] in (errno.EPIPE, errno.ECONNRESET,
 
71
                                  errno.ECONNABORTED,)):
 
72
                self.close_connection = 1
 
73
                pass
 
74
            else:
 
75
                raise
 
76
 
 
77
    def _handle_one_request(self):
 
78
        """
 
79
        Request handling as defined in the base class.
 
80
 
63
81
        You normally don't need to override this method; see the class
64
82
        __doc__ string for information on how to handle specific HTTP
65
83
        commands such as GET and POST.
66
84
 
 
85
        On some platforms, notably OS X, a lot of EAGAIN (resource temporary
 
86
        unavailable) occur. We retry silently at most 10 times.
67
87
        """
68
88
        for i in xrange(1,11): # Don't try more than 10 times
69
89
            try:
326
346
        self._http_base_url = '%s://%s:%s/' % (self._url_protocol,
327
347
                                               self.host,
328
348
                                               self.port)
329
 
        self._http_starting.release()
330
349
        httpd.socket.settimeout(0.1)
 
350
        self._http_starting.release()
331
351
 
332
352
        while self._http_running:
333
353
            try:
380
400
 
381
401
    def tearDown(self):
382
402
        """See bzrlib.transport.Server.tearDown."""
 
403
        self._httpd.server_close()
383
404
        self._http_running = False
384
405
        self._http_thread.join()
385
406