http: and dav:
Both run on the standard library, through a transport that can be replaced.
The transport (HTTPTransport by default), HTTPResponse and the rules for
redirects and credentials are those of pathapi.http; see its
documentation.
uripath.schemes.HTTPURIPath(*uris, **options)
Bases: URIPath
http/https scheme: read/write access over HTTP (PUT/DELETE
for writes/deletes, configurable via with_transport()), listing
directories by scraping an Apache/nginx-style HTML index with a
zero-dependency in-house parser (_DirectoryListingParser). Needs no
third-party library: requests go through HTTPTransport unless a
transport is given.
Source code in src/uripath/_uri.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
backend
instance-attribute
rmdir()
Source code in src/uripath/schemes/_http/_path.py
311 312 313 314 315 316 317 318 319 320 321 322 | |
stat(*, follow_symlinks=True, walk_up_last_modified=False)
Source code in src/uripath/schemes/_http/_path.py
182 183 184 185 186 | |
unlink(missing_ok=False)
Source code in src/uripath/schemes/_http/_path.py
289 290 291 292 293 294 295 296 297 | |
with_session(session, write_method='PUT', append_mode='rewrite', **requests_args)
This path with a backend that sends through a requests.Session
(session=None makes a new one). headers and timeout in
requests_args are the backend's; the others (auth, verify,
proxies, cert, ...) go to the requests transport of
pathapi-requests, which must be installed: without it this raises
ImportError naming it. The caller closes the transport.
Source code in src/uripath/schemes/_http/_path.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
with_transport(transport, *, headers=None, timeout=_settings.DEFAULT_TIMEOUT, write_method='PUT', append_mode='rewrite')
This path with a backend that sends through transport (any object
with a send() method as pathapi.http.HTTPTransport.send();
the caller closes
it). headers go with every request; write_method ("PUT", or
e.g. "POST") uploads on close, and append_mode is "rewrite" or
"patch".
Source code in src/uripath/schemes/_http/_path.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
uripath.schemes.HTTPBackend(transport=None, *, headers=None, timeout=_settings.DEFAULT_TIMEOUT, write_method='PUT', append_mode='rewrite')
Bases: HTTPClient
The transport and the settings shared by an HTTPURIPath tree (see
with_transport() and with_session()): a pathapi.http.HTTPClient
that takes a path or a URL for its address and adds write_method and
append_mode.
transport is any object with a send() method as
pathapi.http.HTTPTransport.send(); without one the backend builds the
built-in HTTPTransport on first use and closes it with close() or at the
end of a with block. A transport it was given stays the caller's.
headers are sent with every request, request-specific headers merged
over them by name; every request gets timeout=(10, 60) seconds unless
timeout here or in the call says otherwise (None waits without limit).
URL userinfo (http://user:password@host/) is never sent inside the
request URL: it is stripped and sent as an Authorization: Basic header
unless headers or the call name one.
The backend, through HTTPClient, follows redirects. GET, HEAD and
OPTIONS follow up to 30; a redirect that changes the scheme, host or
port drops Authorization (and nothing else). Any other method
(PROPFIND, PUT, PATCH, DELETE, MKCOL, MOVE, a write_method
such as POST) is sent without following: a 307 or 308 (for PROPFIND also
a 301, 302 or 303) to the same scheme, host and port is sent once more
with the same method and body, and any other 3xx, a redirect to another
origin or a second redirect raises OSError(EIO).
Source code in src/uripath/schemes/_http/_backend.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
__slots__ = ('write_method', 'append_mode')
class-attribute
instance-attribute
append_mode = append_mode
instance-attribute
write_method = write_method
instance-attribute
__repr__()
Source code in src/uripath/schemes/_http/_backend.py
65 66 | |
redirect(method, uri, resp, *, headers=None, stream=False, timeout=_UNSET)
Send method to where resp, the answer to a request for uri,
redirects to, and follow what it redirects to in turn. The request
carries what uri is sent with, except that Authorization is left
off whenever it goes to another scheme, host or port than uri's.
A redirect with no usable Location is OSError(EIO).
Source code in src/uripath/schemes/_http/_backend.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
request(method, uri, *, data=None, headers=None, stream=False, allow_redirects=None, timeout=_UNSET)
Send method to uri and return the final response. A data
that is not bytes (a file, an iterable) cannot be sent twice, so it
is not re-sent after a redirect or a dropped connection.
allow_redirects=False returns the first answer of a GET, HEAD
or OPTIONS as it is. ValueError for a URL or header with a control
character, before anything is sent.
With stream=False the body is read before this returns, and a decoded
body over pathapi.http.MAX_REPLY_BYTES is OSError(EFBIG); with
stream=True the caller reads it, and closes the response.
Source code in src/uripath/schemes/_http/_backend.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
uripath.schemes.HTTPWriteStream(path, exclusive=False)
Bases: _UploadStream
Source code in src/uripath/schemes/_http/_streams.py
133 134 135 136 137 138 | |
uripath.schemes.HTTPAppendStream(path)
Bases: _UploadStream
Source code in src/uripath/schemes/_http/_streams.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
uripath.schemes.DAVURIPath(*uris, **options)
Bases: HTTPURIPath
dav:/davs: scheme: WebDAV (RFC 4918) over HTTP(S). Extends
HTTPURIPath with PROPFIND (stat/listdir -- real directory metadata,
replacing HTTPURIPath's HTML-index scraping) and PUT/DELETE/MKCOL/MOVE
(full write support). Requests go to the equivalent http:/https:
URL (_wire_uri()); as_uri() still reports dav:/davs:. Reuses
HTTPURIPath's HTTPBackend (transport + settings) -- no new dependency.
rmdir() enforces pathlib's "must be empty" contract with a depth-1
PROPFIND before DELETE (WebDAV DELETE is recursive by spec, RFC 4918,
unlike pathlib.Path.rmdir()). The native recursive DELETE is still
available -- and cheaper than the base class's client-side walk -- via
rm(recursive=True), overridden below to issue a single request.
Source code in src/uripath/_uri.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__SCHEMES = ('dav', 'davs')
class-attribute
instance-attribute
__slots__ = ()
class-attribute
instance-attribute
rename(target)
Source code in src/uripath/schemes/_dav.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
rm(recursive=False, missing_ok=False, ignore_error=False, *, follow_symlinks=False, follow_binds=False)
Source code in src/uripath/schemes/_dav.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
rmdir()
Source code in src/uripath/schemes/_dav.py
387 388 389 390 391 392 393 394 395 396 397 | |
stat(*, follow_symlinks=True, walk_up_last_modified=False)
Source code in src/uripath/schemes/_dav.py
252 253 254 255 256 257 258 259 260 261 262 263 | |
unlink(missing_ok=False)
Source code in src/uripath/schemes/_dav.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
pathapi.http.MAX_REPLY_BYTES (8 MiB) bounds a reply the backend reads
whole, such as a directory index; assign a larger number to allow more.