Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
asyncreq
is a lightweight Python library for making asynchronous HTTP requests using aiohttp
. This library provides two convenient methods for interacting with RESTful APIs in an asynchronous manner.
To install the library, use the following pip command:
pip install asyncreq
make_request
The make_request
method allows you to make asynchronous HTTP requests with flexible options. Here's an example of how to use it:
from asyncreq import make_request
async def example_usage():
url = "https://api.example.com/resource"
method = "GET"
headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}
try:
response_data, status_code, response_headers = await make_request(
url=url,
method=method,
headers=headers,
# Add other optional parameters as needed
)
print(f"Response Data: {response_data}")
print(f"Status Code: {status_code}")
print(f"Response Headers: {response_headers}")
except Exception as e:
print(f"An error occurred: {e}")
request
The request
method is a simplified wrapper around make_request
with added error handling. It raises appropriate exceptions for common HTTP-related errors:
from asyncreq import request, HTTPException
async def example_usage():
url = "https://api.example.com/resource"
method = "GET"
headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}
try:
response_data, status_code, response_headers = await request(
url=url,
method=method,
headers=headers,
# Add other optional parameters as needed
)
print(f"Response Data: {response_data}")
print(f"Status Code: {status_code}")
print(f"Response Headers: {response_headers}")
except HTTPException as e:
print(f"An HTTP error occurred: {e}")
Note: make sure to use await
as demonstrated in the examples above.
If you find any issues or have suggestions for improvements, please feel free to open an issue or create a pull request on the Git repository.
This project is licensed under the MIT license.
FAQs
A lightweight library for making asynchronous HTTP requests.
We found that asyncreq demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.