~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

  • Committer: Vincent Ladeuil
  • Date: 2007-12-21 21:58:06 UTC
  • mto: (3146.3.1 179368) (3156.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3158.
  • Revision ID: v.ladeuil+lp@free.fr-20071221215806-c2kdsnqsi3tvqjr4
Make all the test pass. Looks like we are HTTP/1.1 compliant.

* bzrlib/transport/http/_urllib2_wrappers.py:
Review the debug prints and layered them.
(AbstractAuthHandler.auth_required): Clean up the http pipe before
issuing the new request after a 401 or 407 auth required error.

* bzrlib/tests/test_http.py:
Fix the remaining imports.
(BadStatusRequestHandler.parse_request): Simplified. Close
connection.
(TestInvalidStatusServer.test_http_has,
TestInvalidStatusServer.test_http_get): Document pycurl
limitations.

* bzrlib/tests/http_utils.py:
(RedirectRequestHandler.parse_request, AuthRequestHandler.do_GET):
Add a Content-Length header.

* bzrlib/tests/http_server.py:
(TestingHTTPRequestHandler.get_multiple_ranges): Close the
connection since we didnt specify a Content-Length header.

* bzrlib/tests/http_utils.py:
(RedirectRequestHandler.parse_request): Add a Content-Length
header.

* bzrlib/tests/http_server.py:
(TestingHTTPRequestHandler.handle_one_request): Any socket error
close the connection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        try:
78
78
            SimpleHTTPServer.SimpleHTTPRequestHandler.handle_one_request(self)
79
79
        except socket.error, e:
80
 
            if (len(e.args) > 0
81
 
                and e.args[0] in (errno.EPIPE, errno.ECONNRESET,
82
 
                                  errno.ECONNABORTED,)):
83
 
                self.close_connection = 1
84
 
            else:
 
80
            # Any socket error should close the connection, but some are due to
 
81
            # the client closing early and we don't want to pollute test
 
82
            # results, so we raise only the others.
 
83
            self.close_connection = 1
 
84
            if (len(e.args) == 0
 
85
                or e.args[0] not in (errno.EPIPE, errno.ECONNRESET,
 
86
                                     errno.ECONNABORTED, errno.EBADF)):
85
87
                raise
86
88
 
87
89
    _range_regexp = re.compile(r'^(?P<start>\d+)-(?P<end>\d+)$')
154
156
            self.send_range_content(file, start, end - start + 1)
155
157
        # Final boundary
156
158
        self.wfile.write("--%s\r\n" % boundary)
 
159
        # Close the connection since we didn't specify the Content-Length
 
160
        # FIXME: This is not 1.1 friendly
 
161
        self.close_connection = 1
157
162
 
158
163
    def do_GET(self):
159
164
        """Serve a GET request.