Skip to main content

RawHTTPy

RawHTTPy is a Python package to parse raw HTTP requests into an object, ready to be used to send HTTP requests with web python libraries such as requests or httpx.

This library is very useful when you have to replicate an HTTP request inside your python code but it takes too long to write down all the headers and body parameters (plus all the lines of code it takes).

With RawHTTPy you can pass the raw request as a string to the RawHTTPy class. You will get back an object with the following properties:

  • url
  • host
  • headers
  • body
  • path (url path)
  • method
  • http_version
  • ssl (bool)

NOTE

At the moment RawHTTPy only supports JSON and raw data bodies. It's not functional for file upload requests.

Usage

Python project

Let's assume we have captured a request with a web proxy (e.g. BurpSuite) and we pasted the HTTP request inside the file raw_http_req.txt.

POST /login HTTP/2
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Cookie: session=qwerty123456
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://duckduckgo.com/
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?1
If-Modified-Since: Sat, 30 Dec 2023 15:44:33 GMT
If-None-Match: "65903ae1-83ac"
Te: trailers

username=admin&password=pass
from rawhttpy import RawHTTPy
import requests

# read the raw http request from a text file
with open("raw_http_req.txt", "r") as f:
    raw_req = f.read()

# initialize the RawHTTPy object
rh = RawHTTPy(raw_req)

# you can change all the fields before sending the request
rh.headers['User-Agent'] = 'RawHTTPy Mozilla/5.0'
rh.body['username'] = 'superadmin'
rh.body['password'] = 'securepass'

# add a new item to the body property
rh.body['login'] = '1'

# add a new header
rh.headers['X-MyHeader'] = 'xyz'

# send the request
res = requests.post(rh.url, headers=rh.headers, data=rh.body)

CLI

You can run rawhttpy {req_file} from your CLI to check how the HTTP request will be parsed.

Release files for rawhttpy 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rawhttpy 0.1
File Size Uploaded
rawhttpy-0.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rawhttpy 0.1
File Interpreter ABI Platform
rawhttpy-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / rawhttpy-0.1.tar.gz

Download URL rawhttpy-0.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
99ea87eaa476596bacbad2eb051fbbfe02dd253a5ba9d9934cd551734e2d821e
BLAKE2b-256 checksum
How to use checksums
a8730a2febcb13ed6c066e757b5d6427368a127af7c3cc92ec6582e824fc4d6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.5

Release files / rawhttpy-0.1-py3-none-any.whl

Download URL rawhttpy-0.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47566cdbfe89bd93716aeba3098b3805193ef685e3037334efd557b8311eb775
BLAKE2b-256 checksum
How to use checksums
e086f053ca1d226992bf7ea45ebd6345c805927fc1881005a96b1b87a7e69991
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page