-
Notifications
You must be signed in to change notification settings - Fork 2
HTTP Transport Class
The http_logging.AsyncHttpTransport
Class inherits from logstash_async.transport.HttpTransport
and provides basic functionality to generalize HTTP connections for any backend (apart from LogStash)[about LogStash inheritance].
In general, you will not need to instantiate your own AsyncHttpTransport
objects, since AsyncHttpHandler
already does that for you when instantiated[AsyncHttpHandler.transport].
Three main reasons to create our own HTTP transport class:
- Extend the
send
method and remove theauth
argument to requests to host (particular to how LogStash works, but we wanted an approach agnostic to the backend stack) - Enable adding a path[AsyncHttpHandler.path] to the URL, making it more flexible in connecting to virtually any HTTP API out there
- Allow setting custom HTTP headers in requests to host[custom headers]
The AsyncHttpTransport
is used as an argument to the AsyncHttpHandler
Class[AsyncHttpHandler]:
from http_logging import AsyncHttpHandler, AsyncHttpTransport
host = 'my-domain.com'
handler = AsyncHttpHandler(
host=host,
transport=AsyncHttpTransport(
host=host,
)
)
[about LogStash inheritance] Read more about why we inherit from Python LogStash Async in our documentation ↩
[AsyncHttpHandler.transport] Please refer to the AsyncHttpHandler.transport API reference. ↩
[AsyncHttpHandler.path] Please refer to the AsyncHttpHandler.path attribute API reference. ↩
[custom headers] Please refer to Adding custom HTTP headers to requests in the documentation. ↩
[AsyncHttpHandler] Please refer to the Handler Class documentation. ↩