149
149
user and passwords are not embedded in the path provided to the server.
151
151
relative = urlutils.unescape(relpath).encode('utf-8')
152
path = self._combine_paths(self._path, relative)
152
path = self._combine_paths(self._parsed_url.path, relative)
153
153
return self._unsplit_url(self._unqualified_scheme,
154
None, None, self._host, self._port, path)
154
None, None, self._parsed_url.host,
155
self._parsed_url.port, path)
156
157
def _create_auth(self):
157
158
"""Returns a dict containing the credentials provided at build time."""
158
auth = dict(host=self._host, port=self._port,
159
user=self._user, password=self._password,
159
auth = dict(host=self._parsed_url.host, port=self._parsed_url.port,
160
user=self._parsed_url.user, password=self._parsed_url.password,
160
161
protocol=self._unqualified_scheme,
162
path=self._parsed_url.path)
164
165
def get_smart_medium(self):
413
414
# HTTP URL's are externally usable as long as they don't mention their
414
415
# implementation qualifier
415
416
return self._unsplit_url(self._unqualified_scheme,
416
self._user, self._password,
417
self._host, self._port,
417
self._parsed_url.user, self._parsed_url.password,
418
self._parsed_url.host, self._parsed_url.port,
419
self._parsed_url.path)
420
421
def is_readonly(self):
421
422
"""See Transport.is_readonly."""
526
527
relying on the caller to give us a proper url (i.e. one returned by
527
528
the server mirroring the one we sent).
532
path) = self._split_url(abspath)
534
return path[pl:].strip('/')
530
parsed_url = self._split_url(abspath)
531
pl = len(self._parsed_url.path)
532
return parsed_url.path[pl:].strip('/')
536
534
relpath = relpath(source)
537
535
if not target.endswith(relpath):
541
539
new_transport = None
545
path) = self._split_url(target)
540
parsed_url = self._split_url(target)
546
541
# Recalculate base path. This is needed to ensure that when the
547
542
# redirected tranport will be used to re-try whatever request was
548
543
# redirected, we end up with the same url
549
base_path = path[:-len(relpath)]
550
if scheme in ('http', 'https'):
544
base_path = parsed_url.path[:-len(relpath)]
545
if parsed_url.scheme in ('http', 'https'):
551
546
# Same protocol family (i.e. http[s]), we will preserve the same
552
547
# http client implementation when a redirection occurs from one to
553
548
# the other (otherwise users may be surprised that bzr switches
554
549
# from one implementation to the other, and devs may suffer
556
if (scheme == self._unqualified_scheme
557
and host == self._host
558
and port == self._port
559
and (user is None or user == self._user)):
551
if (parsed_url.scheme == self._unqualified_scheme
552
and parsed_url.host == self._parsed_url.host
553
and parsed_url.port == self._parsed_url.port
554
and (parsed_url.user is None or
555
parsed_url.user == self._parsed_url.user)):
560
556
# If a user is specified, it should match, we don't care about
561
557
# passwords, wrong passwords will be rejected anyway.
562
558
new_transport = self.clone(base_path)
565
561
# credentials (if they don't apply, the redirected to server
566
562
# will tell us, but if they do apply, we avoid prompting the
568
redir_scheme = scheme + '+' + self._impl_name
564
redir_scheme = parsed_url.scheme + '+' + self._impl_name
569
565
new_url = self._unsplit_url(redir_scheme,
570
self._user, self._password,
566
self._parsed_url.user,
567
self._parsed_url.password,
568
parsed_url.host, parsed_url.port,
573
570
new_transport = transport.get_transport(new_url)
575
572
# Redirected to a different protocol
576
new_url = self._unsplit_url(scheme,
573
new_url = self._unsplit_url(parsed_url.scheme,
574
parsed_url.user, parsed_url.password,
575
parsed_url.host, parsed_url.port,
580
577
new_transport = transport.get_transport(new_url)
581
578
return new_transport