b.t.h.HttpTransportBase(ConnectedTransport) : class documentation

Part of bzrlib.transport.http View In Hierarchy

Known subclasses: bzrlib.transport.http._pycurl.PyCurlTransport, bzrlib.transport.http._urllib.HttpTransport_urllib

Base class for http implementations.

Does URL parsing, etc, but not any network IO.

The protocol can be given as e.g. http+urllib://host/ to use a particular implementation.

Method __init__ Set the base path where files will be stored.
Method has Does the file relpath exist?
Method get Get the file at the given relative path.
Method get_smart_medium See Transport.get_smart_medium.
Method recommended_page_size See Transport.recommended_page_size().
Method put_file Copy the file-like object into the location.
Method mkdir Create a directory at the given path.
Method rmdir See Transport.rmdir.
Method append_file Append the text in the file-like object into the final
Method copy Copy the item at rel_from to the location at rel_to
Method copy_to Copy a set of entries from self into another Transport.
Method move Move the item at rel_from to the location at rel_to
Method delete Delete the item at relpath
Method external_url See bzrlib.transport.Transport.external_url.
Method is_readonly See Transport.is_readonly.
Method listable See Transport.listable.
Method stat Return the stat information for a file.
Method lock_read Lock the given file for shared (read) access.
Method lock_write Lock the given file for exclusive (write) access.
Method _get Get a file, or part of a file.
Method _remote_path See ConnectedTransport._remote_path.
Method _create_auth Returns a dict containing the credentials provided at build time.
Method _degrade_range_hint Undocumented
Method _readv Get parts of the file at the given relative path.
Method _coalesce_readv Issue several GET requests to satisfy the coalesced offsets
Method _post POST body_bytes to .bzr/smart on this transport.
Method _attempted_range_header Prepare a HTTP Range header at a level the server should accept.
Static Method _range_header Turn a list of bytes ranges into a HTTP Range header value.
Method _redirected_to Returns a transport suitable to re-issue a redirected request.

Inherited from ConnectedTransport:

Method clone Return a new transport with root at self.base + offset
Method relpath Return the local path portion from a given absolute path
Method abspath Return the full url to the given relative path.
Method disconnect Disconnect the transport.
Method _user Undocumented
Method _password Undocumented
Method _host Undocumented
Method _port Undocumented
Method _path Undocumented
Method _scheme Undocumented
Static Method _split_url Undocumented
Static Method _unsplit_url Build the full URL for the given already URL encoded path.
Method _get_shared_connection Get the object shared amongst cloned transports.
Method _set_connection Record a newly created connection with its associated credentials.
Method _get_connection Returns the transport specific connection object.
Method _get_credentials Returns the credentials used to establish the connection.
Method _update_credentials Update the credentials of the current connection.
Method _reuse_for Returns a transport sharing the same connection if possible.

Inherited from Transport (via ConnectedTransport):

Method create_prefix Create all the directories leading down to self.base.
Method ensure_base Ensure that the directory this transport references exists.
Method get_segment_parameters Return the segment parameters for the top segment of the URL.
Method local_abspath Return the absolute path on the local filesystem.
Method has_multi Return True/False for each entry in relpaths
Method has_any Return True if any of the paths exist.
Method iter_files_recursive Iter the relative paths of files in the transports sub-tree.
Method get_bytes Get a raw string of the bytes for a file at the given location.
Method readv Get parts of the file at the given relative path.
Method get_multi Get a list of file-like objects, one for each entry in relpaths.
Method put_bytes Atomically put the supplied bytes into the given location.
Method put_bytes_non_atomic Copy the string into the target location.
Method put_file_non_atomic Copy the file-like object into the target location.
Method mkdir_multi Create a group of directories
Method open_write_stream Open a writable file stream at relpath.
Method append_bytes Append bytes to a file at relpath.
Method append_multi Append the text in each file-like or string object to
Method copy_multi Copy a bunch of entries.
Method copy_tree Copy a subtree from one relpath to another.
Method copy_tree_to_transport Copy a subtree from one transport to another.
Method rename Rename a file or directory.
Method move_multi Move a bunch of entries.
Method move_multi_to Move a bunch of entries to a single location.
Method delete_multi Queue up a bunch of deletes to be done.
Method delete_tree Delete an entire tree. This may require a listable transport.
Method __repr__ Undocumented
Method stat_multi Stat multiple files and return the information.
Method readlink Return a string representing the path to which the symbolic link points.
Method hardlink Create a hardlink pointing to source named link_name.
Method symlink Create a symlink pointing to source named link_name.
Method list_dir Return a list of all files at the given location.
Method _translate_error Translate an IOError or OSError into an appropriate bzr error.
Method _pump Most children will need to copy from one file-like
Method _get_total Try to figure out how many entries are in multi,
Method _report_activity Notify that this transport has activity.
Method _update_pb Update the progress bar based on the current count
Method _iterate_over Iterate over all entries in multi, passing them to func,
Method _seek_and_read An implementation of readv that uses fp.seek and fp.read.
Method _sort_expand_and_combine Helper for readv.
Static Method _coalesce_offsets Yield coalesced offsets.
Method _can_roundtrip_unix_modebits Return true if this transport can store and retrieve unix modebits.
def __init__(self, base, _impl_name, _from_transport=None):
Set the base path where files will be stored.
def has(self, relpath):
Does the file relpath exist?

Note that some transports MAY allow querying on directories, but this is not part of the protocol. In other words, the results of t.has("a_directory_name") are undefined.

Returns (type: bool)
def get(self, relpath):
Get the file at the given relative path.
ParametersrelpathThe relative path to the file
def _get(self, relpath, ranges, tail_amount=0):
Get a file, or part of a file.
ParametersrelpathPath relative to transport base URL
rangesNone to get the whole file; or a list of _CoalescedOffset to fetch parts of a file.
tail_amountThe amount to get from the end of the file.
Returns(http_code, result_file)
def _remote_path(self, relpath):
See ConnectedTransport._remote_path.

user and passwords are not embedded in the path provided to the server.

def _create_auth(self):
Returns a dict containing the credentials provided at build time.
def get_smart_medium(self):
See Transport.get_smart_medium.
def _degrade_range_hint(self, relpath, ranges, exc_info):
Undocumented
def _readv(self, relpath, offsets):
Get parts of the file at the given relative path.
ParametersoffsetsA list of (offset, size) tuples.
returnA list or generator of (offset, data) tuples
def _coalesce_readv(self, relpath, coalesced):
Issue several GET requests to satisfy the coalesced offsets
def recommended_page_size(self):
See Transport.recommended_page_size().

For HTTP we suggest a large page size to reduce the overhead introduced by latency.

def _post(self, body_bytes):
POST body_bytes to .bzr/smart on this transport.
Returns(response code, response body file-like object).
def put_file(self, relpath, f, mode=None):
Copy the file-like object into the location.
ParametersrelpathLocation to put the contents, relative to base.
fFile-like object.
def mkdir(self, relpath, mode=None):
Create a directory at the given path.
def rmdir(self, relpath):
See Transport.rmdir.
def append_file(self, relpath, f, mode=None):
Append the text in the file-like object into the final location.
def copy(self, rel_from, rel_to):
Copy the item at rel_from to the location at rel_to
def copy_to(self, relpaths, other, mode=None, pb=None):

Copy a set of entries from self into another Transport.

TODO: if other is LocalTransport, is it possible to
do better than put(get())?
ParametersrelpathsA list/generator of entries to be copied.
def move(self, rel_from, rel_to):
Move the item at rel_from to the location at rel_to
def delete(self, relpath):
Delete the item at relpath
def external_url(self):
See bzrlib.transport.Transport.external_url.
def is_readonly(self):
See Transport.is_readonly.
def listable(self):
See Transport.listable.
def stat(self, relpath):
Return the stat information for a file.
def lock_read(self, relpath):
Lock the given file for shared (read) access. :return: A lock object, which should be passed to Transport.unlock()
def lock_write(self, relpath):
Lock the given file for exclusive (write) access. WARNING: many transports do not support this, so trying avoid using it
ReturnsA lock object, which should be passed to Transport.unlock()
def _attempted_range_header(self, offsets, tail_amount):
Prepare a HTTP Range header at a level the server should accept.
Returnsthe range header representing offsets/tail_amount or None if no header can be built.
@staticmethod
def _range_header(ranges, tail_amount):
Turn a list of bytes ranges into a HTTP Range header value.

At least a non-empty ranges or a tail_amount must be provided.

ParametersrangesA list of _CoalescedOffset
tail_amountThe amount to get from the end of the file.
ReturnsHTTP range header string.
def _redirected_to(self, source, target):
Returns a transport suitable to re-issue a redirected request.

The redirection can be handled only if the relpath involved is not renamed by the redirection.

ParameterssourceThe source url as returned by the server.
targetThe target url as returned by the server.
ReturnsA transport or None.
API Documentation for Bazaar, generated by pydoctor at 2020-09-27 01:30:40.