azure.core.pipeline.transport package¶
Module contents¶
-
class
azure.core.pipeline.transport.
HttpTransport
[source]¶ Bases:
contextlib.AbstractContextManager
,abc.ABC
,typing.Generic
An http sender ABC.
-
send
(request, **kwargs)[source]¶ Send the request using this HTTP sender.
Parameters: request (PipelineRequest) – The pipeline request object Returns: The pipeline response object. Return type: PipelineResponse
-
-
class
azure.core.pipeline.transport.
HttpRequest
(method, url, headers=None, files=None, data=None)[source]¶ Bases:
object
Represents a HTTP request.
URL can be given without query parameters, to be added later using “format_parameters”.
Parameters: -
format_parameters
(params)[source]¶ Format parameters into a valid query string. It’s assumed all parameters have already been quoted as valid URL strings.
Parameters: params (dict) – A dictionary of parameters.
-
prepare_multipart_body
()[source]¶ Will prepare the body of this request according to the multipart information.
This call assumes the on_request policies have been applied already in their correct context (sync/async)
Does nothing if “set_multipart_mixed” was never called.
-
set_bytes_body
(data)[source]¶ Set generic bytes as the body of the request.
Will set content-length.
Parameters: data (bytes) – The request field data.
-
set_formdata_body
(data=None)[source]¶ Set form-encoded data as the body of the request.
Parameters: data (dict) – The request field data.
-
set_json_body
(data)[source]¶ Set a JSON-friendly object as the body of the request.
Parameters: data – A JSON serializable object
-
set_multipart_mixed
(*requests, **kwargs)[source]¶ Set the part of a multipart/mixed.
Only support args for now are HttpRequest objects.
boundary is optional, and one will be generated if you don’t provide one. Note that no verification are made on the boundary, this is considered advanced enough so you know how to respect RFC1341 7.2.1 and provide a correct boundary.
Keyword Arguments: - policies (list[SansIOHTTPPolicy]) – SansIOPolicy to apply at preparation time
- boundary (str) – Optional boundary
Parameters: requests – HttpRequests object
-
set_streamed_data_body
(data)[source]¶ Set a streamable data body.
Parameters: data (stream or generator or asyncgenerator) – The request field data.
-
-
class
azure.core.pipeline.transport.
HttpResponse
(request, internal_response, block_size=None)[source]¶ Bases:
azure.core.pipeline.transport._base._HttpResponseBase
-
parts
()[source]¶ Assuming the content-type is multipart/mixed, will return the parts as an iterator.
Return type: iterator[HttpResponse] Raises: ValueError – If the content is not multipart/mixed
-
-
class
azure.core.pipeline.transport.
RequestsTransport
(**kwargs)[source]¶ Bases:
azure.core.pipeline.transport._base.HttpTransport
Implements a basic requests HTTP sender.
Since requests team recommends to use one session per requests, you should not consider this class as thread-safe, since it will use one Session per instance.
In this simple implementation: - You provide the configured session if you want to, or a basic session is created. - All kwargs received by “send” are sent to session.request directly
Keyword Arguments: Example:
-
send
(request, **kwargs)[source]¶ Send request object according to configuration.
Parameters: request (HttpRequest) – The request object to be sent.
Returns: An HTTPResponse object.
Return type: Keyword Arguments: - session (requests.Session) – will override the driver session and use yours. Should NOT be done unless really required. Anything else is sent straight to requests.
- proxies (dict) – will define the proxy to use. Proxy is a dict (protocol, url)
-
-
class
azure.core.pipeline.transport.
RequestsTransportResponse
(request, requests_response, block_size=None)[source]¶ Bases:
azure.core.pipeline.transport._base.HttpResponse
,azure.core.pipeline.transport._requests_basic._RequestsTransportResponseBase
Streaming of data from the response.
-
class
azure.core.pipeline.transport.
AsyncHttpTransport
[source]¶ Bases:
contextlib.AbstractAsyncContextManager
,abc.ABC
,typing.Generic
An http sender ABC.
-
class
azure.core.pipeline.transport.
AsyncHttpResponse
(request, internal_response, block_size=None)[source]¶ Bases:
azure.core.pipeline.transport._base._HttpResponseBase
An AsyncHttpResponse ABC.
Allows for the asynchronous streaming of data from the response.
-
parts
() → collections.abc.AsyncIterator[source]¶ Assuming the content-type is multipart/mixed, will return the parts as an async iterator.
Return type: AsyncIterator Raises: ValueError – If the content is not multipart/mixed
-
-
class
azure.core.pipeline.transport.
AsyncioRequestsTransport
(**kwargs)[source]¶ Bases:
azure.core.pipeline.transport._base_requests_async.RequestsAsyncTransportBase
Identical implementation as the synchronous RequestsTransport wrapped in a class with asynchronous methods. Uses the built-in asyncio event loop.
Example:
-
send
(request: azure.core.pipeline.transport._base.HttpRequest, **kwargs) → azure.core.pipeline.transport._base_async.AsyncHttpResponse[source]¶ Send the request using this HTTP sender.
Parameters: request (HttpRequest) – The HttpRequest
Returns: The AsyncHttpResponse
Return type: Keyword Arguments: - session (requests.Session) – will override the driver session and use yours. Should NOT be done unless really required. Anything else is sent straight to requests.
- proxies (dict) – will define the proxy to use. Proxy is a dict (protocol, url)
-
-
class
azure.core.pipeline.transport.
AsyncioRequestsTransportResponse
(request, requests_response, block_size=None)[source]¶ Bases:
azure.core.pipeline.transport._base_async.AsyncHttpResponse
,azure.core.pipeline.transport._requests_basic.RequestsTransportResponse
Asynchronous streaming of data from the response.
-
class
azure.core.pipeline.transport.
AioHttpTransport
(*, session=None, loop=None, session_owner=True, **kwargs)[source]¶ Bases:
azure.core.pipeline.transport._base_async.AsyncHttpTransport
AioHttp HTTP sender implementation.
Fully asynchronous implementation using the aiohttp library.
Parameters: - session – The client session.
- loop – The event loop.
- session_owner (bool) – Session owner. Defaults True.
Keyword Arguments: use_env_settings (bool) – Uses proxy settings from environment. Defaults to True.
Example:
-
send
(request: azure.core.pipeline.transport._base.HttpRequest, **config) → Optional[azure.core.pipeline.transport._base_async.AsyncHttpResponse][source]¶ Send the request using this HTTP sender.
Will pre-load the body into memory to be available with a sync method. Pass stream=True to avoid this behavior.
Parameters: - request (HttpRequest) – The HttpRequest object
- config – Any keyword arguments
Returns: The AsyncHttpResponse
Return type: Keyword Arguments:
-
class
azure.core.pipeline.transport.
AioHttpTransportResponse
(request: azure.core.pipeline.transport._base.HttpRequest, aiohttp_response: aiohttp.client_reqrep.ClientResponse, block_size=None)[source]¶ Bases:
azure.core.pipeline.transport._base_async.AsyncHttpResponse
Methods for accessing response body data.
Parameters: - request (HttpRequest) – The HttpRequest object
- aiohttp_response (aiohttp.ClientResponse object) – Returned from ClientSession.request().
- block_size (int) – block size of data sent over connection.