Skip to main content

No project description provided

Project description

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.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rawhttpy-0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rawhttpy-0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file rawhttpy-0.1.tar.gz.

File metadata

  • Download URL: rawhttpy-0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for rawhttpy-0.1.tar.gz
Algorithm Hash digest
SHA256 99ea87eaa476596bacbad2eb051fbbfe02dd253a5ba9d9934cd551734e2d821e
MD5 aaf33f8b284690bbfd5d854f922a70a3
BLAKE2b-256 a8730a2febcb13ed6c066e757b5d6427368a127af7c3cc92ec6582e824fc4d6c

See more details on using hashes here.

File details

Details for the file rawhttpy-0.1-py3-none-any.whl.

File metadata

  • Download URL: rawhttpy-0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for rawhttpy-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 47566cdbfe89bd93716aeba3098b3805193ef685e3037334efd557b8311eb775
MD5 a350fd1e5ecc01563c82ff2024508db3
BLAKE2b-256 e086f053ca1d226992bf7ea45ebd6345c805927fc1881005a96b1b87a7e69991

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page