morpheus.utils.http_utils#
HTTP utilities
Module Attributes
Optional callback function invoked by |
Functions
|
Verifies that |
|
Wrapper around |
Classes
|
Not a complete list of HTTP methods, just the ones we use. |
|
A tuple consisting of the HTTP status code, mime type to be used for the Content-Type header, the body of the response and an optional callback function to be invoked once the response is completed. |
|
Not a complete list of mime types, just the ones we use. |
- HttpOnCompleteCallbackFn#
Optional callback function invoked by
morpheus.common.HttpServeronce a response is completed, either successfully or encountered a failure.- Parameters:
- prepare_url(url)[source]#
Verifies that
urlcontains a protocol scheme and a host and returns the url. If no protocol scheme is provided,httpis used.
- request_with_retry(
- request_kwargs,
- requests_session=None,
- max_retries=10,
- sleep_time=0.1,
- accept_status_codes=(HTTPStatus.OK,),
- respect_retry_after_header=True,
- on_success_fn=None,
Wrapper around
requests.requestthat retries on failure.This code is a work-around for an issue (urllib3/urllib3#2751), in urllib3’s Retry class and should be removed once it is resolved.
Upon successfull completion, the
on_success_fnis called (if notNone) with the response object. Whenon_success_fnisNone, a tuple containing the request session and the response object is returned, otherwise a tuple containing the request session and the return value ofon_success_fnis returned.If
on_success_fnraises an exception, it is treated as a failure and the request is retried.