
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Report Bug · Request Feature · Ask Question · Report security bug
requests-pprint
is a Python library that allows you to print your HTTP requests and responses in a pretty format. It is based on the requests
library and uses the rich
library to print the response in a more readable way.
Here's a breakdown of the packages needed and their versions:
[!NOTE]
The software has been developed and tested using Python3.12.1
. The minimum required version to run the software is Python 3.6. Although the software may work with previous versions, it is not guaranteed.
requests-pprint
can be installed easily as a PyPI package. Just run the following command:
pip3 install requests-pprint
[!IMPORTANT]
For best practices and to avoid potential conflicts with your global Python environment, it is strongly recommended to install this program within a virtual environment. Avoid using the --user option for global installations. We highly recommend using pipx for a safe and isolated installation experience. Therefore, the appropriate command to installrequests-pprint
would be:pipx install requests-pprint
If you prefer to install the program manually, follow these steps:
[!NOTE]
This will install the version from the latest commit, not the latest release.
Download the latest version of requests-pprint from this repository:
git clone https://github.com/YisusChrist/requests-pprint
cd requests-pprint
Install the package:
poetry install --only main
If you installed it from PyPI, you can use the following command:
pipx uninstall requests-pprint
import requests
from requests_pprint import pprint_http_request
# Prepare a sample HTTP request
url = 'https://api.example.com'
headers = {'User-Agent': 'Mozilla/5.0'}
body = {'key': 'value'}
request = requests.Request('POST', url, headers=headers, json=body)
prepared_request = request.prepare()
# Print the formatted HTTP request
pprint_http_request(prepared_request)
Output:
import requests
from requests_pprint import pprint_http_response
# Send a sample HTTP request
response = requests.get('https://example.com')
# Print the formatted HTTP response
pprint_http_response(response)
Output:
import requests
from requests_pprint import print_response_summary
# Send a sample HTTP request
response = requests.get('https://example.com')
# Print a summary of the HTTP response
print_response_summary(response)
Output:
Since 2024-07-28, requests-pprint
supports asynchronous requests from the aiohttp library. You can use the pprint_async_http_request
and pprint_async_http_response
functions to print the formatted HTTP request and response, respectively, as well as the print_async_response_summary
function to print a summary of the HTTP response.
Here is an example of how to use these functions:
import asyncio
import aiohttp
from requests_pprint import pprint_async_http_response
async def main():
async with aiohttp.ClientSession() as session:
url = "https://api.example.com"
headers = {"User-Agent": "Mozilla/5.0"}
body = {"key": "value"}
async with session.post(url, headers=headers, json=body) as response:
await pprint_async_http_response(response)
asyncio.run(main())
Output:
import asyncio
import aiohttp
from requests_pprint import print_async_response_summary
async def main():
async with aiohttp.ClientSession() as session:
url = "https://api.example.com"
headers = {"User-Agent": "Mozilla/5.0"}
body = {"key": "value"}
async with session.post(url, headers=headers, json=body) as response:
await print_async_response_summary(response)
asyncio.run(main())
Output:
Before you participate in our delightful community, please read the code of conduct.
I'm far from being an expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull requests. So take a look through the open issues and help where you can.
See Contributing Guidelines for more details.
requests-pprint
is released under the GPL-3.0 License.
FAQs
Pretty print your python HTTP requests
We found that requests-pprint 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.