b.t.h.TestingHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler) : class documentation

Part of bzrlib.tests.http_server View In Hierarchy

Known subclasses: bzrlib.plugins.launchpad.test_lp_directory.PredefinedRequestHandler, bzrlib.tests.http_utils.AuthRequestHandler, bzrlib.tests.http_utils.RedirectRequestHandler, bzrlib.tests.http_utils.SmartRequestHandler, bzrlib.tests.test_http.BadProtocolRequestHandler, bzrlib.tests.test_http.BadStatusRequestHandler, bzrlib.tests.test_http.ForbiddenRequestHandler, bzrlib.tests.test_http.ForbiddenRequestHandler 0, bzrlib.tests.test_http.InvalidStatusRequestHandler, bzrlib.tests.test_http.LimitedRangeRequestHandler, bzrlib.tests.test_http.MultipleRangeWithoutContentLengthRequestHandler, bzrlib.tests.test_http.NoRangeRequestHandler, bzrlib.tests.test_http.PredefinedRequestHandler, bzrlib.tests.test_http.SingleOnlyRangeRequestHandler, bzrlib.tests.test_http.SingleRangeRequestHandler, bzrlib.tests.test_http.TruncatedBeforeBoundaryRequestHandler, bzrlib.tests.test_http.TruncatedMultipleRangeRequestHandler, bzrlib.tests.test_http.WallRequestHandler

Handles one request.

A TestingHTTPRequestHandler is instantiated for every request received by the associated server. Note that 'request' here is inherited from the base TCPServer class, for the HTTP server it is really a connection which itself will handle one or several HTTP requests.

Method setup Undocumented
Method log_message Undocumented
Method handle Undocumented
Method handle_one_request Handle a single HTTP request.
Method send_error Send and log an error reply.
Method send_head Overrides base implementation to work around a bug in python2.5.
Method send_range_content Undocumented
Method get_single_range Undocumented
Method get_multiple_ranges Undocumented
Method do_GET Serve a GET request.
Method translate_path Translate a /-separated PATH to the local filename syntax.
Method _handle_one_request Undocumented
Method _parse_ranges Parse the range header value and returns ranges.
Method _header_line_length Undocumented
Method _translate_path Translate a /-separated PATH to the local filename syntax.
def setup(self):
Undocumented
def log_message(self, format, *args):
Undocumented
def handle(self):
Undocumented
def handle_one_request(self):
Handle a single HTTP request.

We catch all socket errors occurring when the client close the connection early to avoid polluting the test results.

def send_error(self, code, message=None):
Send and log an error reply.

We redefine the python-provided version to be able to set a Content-Length header as some http/1.1 clients complain otherwise (see bug #568421).

ParameterscodeThe HTTP error code.
messageThe explanation of the error code, Defaults to a short entry.
def _handle_one_request(self):
Undocumented
def _parse_ranges(self, ranges_header, file_size):
Parse the range header value and returns ranges.

RFC2616 14.35 says that syntactically invalid range specifiers MUST be ignored. In that case, we return None instead of a range list.

Parametersranges_headerThe 'Range' header value.
file_sizeThe size of the requested file.
ReturnsA list of (start, end) tuples or None if some invalid range specifier is encountered.
def _header_line_length(self, keyword, value):
Undocumented
def send_head(self):
Overrides base implementation to work around a bug in python2.5.
def send_range_content(self, file, start, length):
Undocumented
def get_single_range(self, file, file_size, start, end):
Undocumented
def get_multiple_ranges(self, file, file_size, ranges):
Undocumented
def do_GET(self):
Serve a GET request.

Handles the Range header.

def translate_path(self, path):
Translate a /-separated PATH to the local filename syntax.

If the server requires it, proxy the path before the usual translation

def _translate_path(self, path):
Translate a /-separated PATH to the local filename syntax.

Note that we're translating http URLs here, not file URLs. The URL root location is the server's startup directory. Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

Override from python standard library to stop it calling os.getcwd()

API Documentation for Bazaar, generated by pydoctor at 2019-08-22 00:28:44.