/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/transport/http/_urllib2_wrappers.py

  • Committer: Jelmer Vernooij
  • Date: 2018-06-20 21:37:51 UTC
  • mto: (6973.12.2 python3-k)
  • mto: This revision was merged to the branch mainline in revision 7010.
  • Revision ID: jelmer@jelmer.uk-20180620213751-h41rae89r47ubfuk
Fix more http tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
                data = self.read(min(self.length, self._discarded_buf_size))
335
335
                pending += len(data)
336
336
            if pending:
337
 
                trace.mutter("%s bytes left on the HTTP socket", pending)
 
337
                trace.mutter("%d bytes left on the HTTP socket", pending)
338
338
            self.close()
339
339
        return pending
340
340
 
409
409
    def __init__(self, host, port=None, proxied_host=None,
410
410
                 report_activity=None, ca_certs=None):
411
411
        AbstractHTTPConnection.__init__(self, report_activity=report_activity)
412
 
        # Use strict=True since we don't support HTTP/0.9
413
 
        http_client.HTTPConnection.__init__(self, host, port, strict=True)
 
412
        http_client.HTTPConnection.__init__(self, host, port)
414
413
        self.proxied_host = proxied_host
415
414
        # ca_certs is ignored, it's only relevant for https
416
415
 
427
426
                 proxied_host=None,
428
427
                 report_activity=None, ca_certs=None):
429
428
        AbstractHTTPConnection.__init__(self, report_activity=report_activity)
430
 
        # Use strict=True since we don't support HTTP/0.9
431
429
        http_client.HTTPSConnection.__init__(self, host, port,
432
 
                                         key_file, cert_file, strict=True)
 
430
                                         key_file, cert_file)
433
431
        self.proxied_host = proxied_host
434
432
        self.ca_certs = ca_certs
435
433
 
525
523
 
526
524
    def set_proxy(self, proxy, type):
527
525
        """Set the proxy and remember the proxied host."""
528
 
        host, port = urllib.splitport(self.get_host())
 
526
        (scheme, user, password, host, port, path) = urlutils.parse_url(
 
527
                self.get_full_url())
529
528
        if port is None:
530
529
            # We need to set the default port ourselves way before it gets set
531
530
            # in the HTTP[S]Connection object at build time.
592
591
        self.ca_certs = ca_certs
593
592
 
594
593
    def create_connection(self, request, http_connection_class):
595
 
        host = request.get_host()
 
594
        full_url = request.get_full_url()
 
595
        (scheme, user, password, host, port, path) = urlutils.parse_url(full_url)
596
596
        if not host:
597
597
            # Just a bit of paranoia here, this should have been
598
598
            # handled in the higher levels
599
 
            raise urlutils.InvalidURL(request.get_full_url(), 'no host given.')
 
599
            raise urlutils.InvalidURL(full_url, 'no host given.')
600
600
 
601
601
        # We create a connection (but it will not connect until the first
602
602
        # request is made)
603
603
        try:
604
604
            connection = http_connection_class(
605
 
                host, proxied_host=request.proxied_host,
 
605
                host, port=port, proxied_host=request.proxied_host,
606
606
                report_activity=self._report_activity,
607
607
                ca_certs=self.ca_certs)
608
608
        except http_client.InvalidURL as exception:
609
609
            # There is only one occurrence of InvalidURL in http_client
610
 
            raise urlutils.InvalidURL(request.get_full_url(),
 
610
            raise urlutils.InvalidURL(full_url,
611
611
                                    extra='nonnumeric port')
612
612
 
613
613
        return connection
777
777
 
778
778
        try:
779
779
            method = request.get_method()
780
 
            url = request.get_selector()
781
 
            connection._send_request(method, url,
 
780
            # TODO(jelmer): Only call parse_url once for every request?
 
781
            (scheme, user, password, host, port, url) = urlutils.parse_url(request.get_full_url())
 
782
            connection.request(method, url,
782
783
                                     # FIXME: implements 100-continue
783
784
                                     #None, # We don't send the body yet
784
 
                                     request.get_data(),
 
785
                                     request.data,
785
786
                                     headers)
786
787
            if 'http' in debug.debug_flags:
787
788
                trace.mutter('> %s %s' % (method, url))