request
dev_tool.services.request
__all__ = ['RequestService']
module-attribute
RequestService
A singleton service class for HTTP request operations.
This class provides methods for making HTTP requests with connection pooling, timeout handling, and automatic error management.
The constructor for the RequestService class.
Parameters:
-
timeout(float, default:360.0) –The request timeout in seconds.
-
connect_timeout(float, default:5.0) –The connection timeout in seconds.
-
max_keepalive_connections(int, default:5) –The maximum number of keepalive connections.
-
max_connections(int, default:10) –The maximum number of total connections.
Source code in dev_tool/services/request/service.py
client = httpx.Client(follow_redirects=True, limits=(httpx.Limits(max_keepalive_connections=max_keepalive_connections, max_connections=max_connections)), timeout=(httpx.Timeout(timeout, connect=connect_timeout)))
instance-attribute
__new__
A method that implements the singleton pattern for the RequestService.
Returns:
-
Self–The singleton RequestService instance.
Source code in dev_tool/services/request/service.py
close
request
A method that makes a generic HTTP request.
Parameters:
-
method(str) –The HTTP method to use.
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
get
A method that makes a GET request.
Parameters:
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
post
A method that makes a POST request.
Parameters:
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
put
A method that makes a PUT request.
Parameters:
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
delete
A method that makes a DELETE request.
Parameters:
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
patch
A method that makes a PATCH request.
Parameters:
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
Response–The HTTP response object.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.
Source code in dev_tool/services/request/service.py
stream
A method that creates a streaming HTTP request.
Parameters:
-
method(str) –The HTTP method to use.
-
url(str) –The URL to request.
-
kwargs–Additional parameters for the request.
Returns:
-
ContextManager[Response]–A context manager for the streaming response.
Raises:
-
HttpTimeoutError–If the request times out.
-
HttpConnectionError–If the connection fails.
-
HttpRequestError–If the request fails.