comicbox.readinglists.sources.url ¶
Fetch a reading list from a URL, streamed and bounded.
A body is read raw and capped on the wire; a gzip or deflate body is inflated here, never past the cap, and any other encoding is refused. So a few kilobytes that would inflate to gigabytes cost no more memory than the cap. A whole download has a deadline, and a cancel is honoured between chunks.
Download dataclass ¶
A fetched body, with the status and headers it came with.
Source code in comicbox/readinglists/sources/url.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
HttpStatusError ¶
Bases: ReadingListFetchError
A fetch the server answered with an error status.
Source code in comicbox/readinglists/sources/url.py
53 54 55 56 57 58 59 60 | |
__init__(url, response) ¶
Name the URL and the status; keep the status and headers.
Source code in comicbox/readinglists/sources/url.py
56 57 58 59 60 | |
check_url(url) ¶
Refuse anything but an http or https URL.
Source code in comicbox/readinglists/sources/url.py
109 110 111 112 113 114 | |
download(client, url, max_bytes, headers=None, *, cancelled=None) ¶
Download a URL’s body, sending headers with the request.
Redirects are followed, but only to http and https. A 304 comes back with an empty body. An error status raises HttpStatusError; a network failure, a body over max_bytes in either its sent or its inflated size, an encoding other than gzip or deflate, or a download past DEADLINE_SECONDS, ReadingListFetchError. cancelled is asked between chunks; when it says yes, OnlineLookupAbortedError.
Source code in comicbox/readinglists/sources/url.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
fetch(client, url, max_bytes, *, cancelled=None) ¶
Download a URL’s body and a revision for it, as download does.
Source code in comicbox/readinglists/sources/url.py
271 272 273 274 275 276 277 278 279 280 | |
without_userinfo(url) ¶
Drop a URL’s user name and password, keeping the rest of the address.
They are sent with the request and never recorded or shown. The query string stays: it is part of the address.
Source code in comicbox/readinglists/sources/url.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |