/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 breezy/tests/test_http.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-07 02:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200207021430-m49iq3x4x8xlib6x
Drop python2 support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# TODO: Should be renamed to breezy.transport.http.tests?
24
24
# TODO: What about renaming to breezy.tests.transport.http ?
25
25
 
26
 
try:
27
 
    from http.client import UnknownProtocol, parse_headers
28
 
    from http.server import SimpleHTTPRequestHandler
29
 
except ImportError:  # python < 3
30
 
    from httplib import UnknownProtocol
31
 
    from SimpleHTTPServer import SimpleHTTPRequestHandler
 
26
from http.client import UnknownProtocol, parse_headers
 
27
from http.server import SimpleHTTPRequestHandler
32
28
import io
33
29
import socket
34
30
import sys
50
46
from ..bzr import (
51
47
    remote as _mod_remote,
52
48
    )
53
 
from ..sixish import PY3
54
49
from . import (
55
50
    features,
56
51
    http_server,
1949
1944
    def _handle_one_request(self):
1950
1945
        tcs = self.server.test_case_server
1951
1946
        requestline = self.rfile.readline()
1952
 
        if PY3:
1953
 
            headers = parse_headers(self.rfile)
1954
 
            bytes_read = len(headers.as_bytes())
1955
 
            bytes_read += headers.as_bytes().count(b'\n')
1956
 
            bytes_read += len(requestline)
1957
 
        else:
1958
 
            headers = self.MessageClass(self.rfile, 0)
1959
 
            # We just read: the request, the headers, an empty line indicating the
1960
 
            # end of the headers.
1961
 
            bytes_read = len(requestline)
1962
 
            for line in headers.headers:
1963
 
                bytes_read += len(line)
1964
 
            bytes_read += len(b'\r\n')
 
1947
        headers = parse_headers(self.rfile)
 
1948
        bytes_read = len(headers.as_bytes())
 
1949
        bytes_read += headers.as_bytes().count(b'\n')
 
1950
        bytes_read += len(requestline)
1965
1951
        if requestline.startswith(b'POST'):
1966
1952
            # The body should be a single line (or we don't know where it ends
1967
1953
            # and we don't want to issue a blocking read)