dicogis.utils.http.client module¶
Contract of the HTTP clients: what the publication code expects from the network.
Depends on neither requests nor Qt, in the same spirit as dicogis.utils.progress.ProgressReporter: the backends implement it, the publication code only knows about it.
- class dicogis.utils.http.client.HttpClient(*args, **kwargs)¶
Bases:
ProtocolWhat the publication code needs to reach a catalog.
Implementations are stateless, cookies included: what a request sends is what its caller gives. Each backend otherwise has its own cookie jar, which overrides the Cookie header once it holds a cookie for the host.
- __init__(*args, **kwargs)¶
- request(method, url, *, params=None, headers=None, data=None, timeout=None)¶
Send a request and wait for its response, redirections being followed.
- Parameters:
- Raises:
HttpTransportError – if no response was received
- Return type:
- Returns:
response, whatever its status code
- exception dicogis.utils.http.client.HttpError¶
Bases:
ExceptionBase class of the errors raised by the HTTP clients.
- class dicogis.utils.http.client.HttpResponse(status_code, headers=<factory>, cookies=<factory>, content=b'', url='')¶
Bases:
objectAn HTTP response, whatever the backend which received it.
- status_code¶
HTTP status code
- headers¶
headers, names in lowercase
- cookies¶
cookies set by this very response, by name
- content¶
body
- url¶
final URL of the request
- __init__(status_code, headers=<factory>, cookies=<factory>, content=b'', url='')¶
- raise_for_status()¶
Raise an error if the response tells one.
- Raises:
HttpStatusError – if the status code is 400 or above
- Return type:
- exception dicogis.utils.http.client.HttpStatusError(response)¶
Bases:
HttpErrorAn HTTP response was received, telling an error.
- response¶
the response at stake
- __init__(response)¶
Build the error from its response.
- Parameters:
response (
HttpResponse) – the response at stake