✨ Features
- Parse raw HTTP Request/ Response strings
- Access and manipulate all HTTP fields: method, path, query, fragment, headers, cookies, body, etc
- Reconstruct HTTP Request/ Response from parsed objects, with automatic Content-Length update
- Easy integration for security testing, automation, or log analysis tools
🛠️ Installation
From PyPI:
pip install TP-HTTP-Request-Response-Parser
From Source:
git clone https://github.com/TPCyberSec/TP-HTTP-Request-Response-Parser.git --branch <Branch/Tag>
cd TP-HTTP-Request-Response-Parser
python -m build
python -m pip install dist/tp_http_request_response_parser-<version>-py3-none-any.whl
📘 Basic Usage
TP_HTTP_REQUEST_PARSER
- request_method: returns the HTTP method (e.g.,
GET,POST) - request_paths: returns the request path parts as JSON_DUPLICATE_KEYS object
- request_queryParams: returns parsed query parameters as JSON_DUPLICATE_KEYS object
- request_fragment: returns the URL fragment
- request_httpVersion: returns the HTTP version (e.g.,
HTTP/1.1,HTTP/2) - request_headers: returns all request headers as JSON_DUPLICATE_KEYS object
- request_cookies: returns all cookies as JSON_DUPLICATE_KEYS object
- request_body: returns the request body as JSON_DUPLICATE_KEYS object
- unparse: reconstructs the HTTP request string from the parsed data. If
update_content_length=True, automatically updates the Content-Length header
from TP_HTTP_Request_Response_Parser import TP_HTTP_REQUEST_PARSER
rawRequest = """GET /v1/promo/extension HTTP/2
Host: d2y7f743exec8w.cloudfront.net
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.97 Safari/537.36
Connection: close
Cache-Control: max-age=0
"""
# Parsing HTTP Request
RequestParser = TP_HTTP_REQUEST_PARSER(rawRequest, ordered_dict=True)
print("- request_method: {}".format(RequestParser.request_method))
print("- request_paths: {}".format(RequestParser.request_paths.dumps(indent=4)))
print("- request_queryParams: {}".format(RequestParser.request_queryParams.dumps(indent=4)))
print("- request_fragment: {}".format(RequestParser.request_fragment))
print("- request_httpVersion: {}".format(RequestParser.request_httpVersion))
print("- request_headers: {}".format(RequestParser.request_headers.dumps(indent=4)))
print("- request_cookies: {}".format(RequestParser.request_cookies.dumps(indent=4)))
print("- request_body: {}".format(RequestParser.request_body.dumps(indent=4)))
print(RequestParser.unparse(update_content_length=True))
TP_HTTP_RESPONSE_PARSER
- response_httpVersion: returns the HTTP version from the response (e.g.,
HTTP/1.1,HTTP/2) - response_statusCode: returns the response status code (e.g.,
200,404) - response_statusText: returns the status text (e.g.,
OK,Not Found) - response_headers: returns all response headers as JSON_DUPLICATE_KEYS object
- response_cookies: returns all response cookies as JSON_DUPLICATE_KEYS object
- response_body: returns the response body as JSON_DUPLICATE_KEYS object
- unparse: reconstructs the HTTP response string from the parsed data. If
update_content_length=True, automatically updates the Content-Length header
from TP_HTTP_Request_Response_Parser import TP_HTTP_RESPONSE_PARSER
rawResponse = """HTTP/2 200 OK
Content-Type: application/json; charset=utf-8
Server: nginx
Date: Mon, 21 Aug 2023 03:55:08 GMT
Etag: W/"846e0a9b390c273d2d7a6843085411d1"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 06024e22-f233-4517-b0f6-f444c8464e7b
Strict-Transport-Security: max-age=63072000; includeSubDomains
Strict-Transport-Security: max-age=63072000; preload
Vary: Accept-Encoding,Accept
X-Cache: Miss from cloudfront
Via: 1.1 19175f36fb9c16ba394561bae28598da.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: SGN50-P2
X-Amz-Cf-Id: eKssgTNGDCswPiQtSYFD1MRNBJCTHEbnQp4MQjtQx2B4eM7oqXYIHg==
{"ok":true,"promo":[]}"""
# Parsing HTTP Response
ResponseParser = TP_HTTP_RESPONSE_PARSER(rawResponse, ordered_dict=True)
print("- response_httpVersion: {}".format(ResponseParser.response_httpVersion))
print("- response_statusCode: {}".format(ResponseParser.response_statusCode))
print("- response_statusText: {}".format(ResponseParser.response_statusText))
print("- response_headers: {}".format(ResponseParser.response_headers.dumps(indent=4)))
print("- response_cookies: {}".format(ResponseParser.response_cookies.dumps(indent=4)))
print("- response_body: {}".format(ResponseParser.response_body.dumps(indent=4)))
print(ResponseParser.unparse(update_content_length=True))
👥 Contributors
📝 CHANGELOG
TP-HTTP-Request-Response-Parser v2026.5.18
- New: Support parsing and unparsing XML Request/ Response body
- Updated: Handle errors when unparsing multipart/form-data and application/x-www-form-urlencoded request bodies with dict or list values
- Updated: Fixed issues related to parsing and unparsing HTTP request/ response
TP-HTTP-Request-Response-Parser v2025.9.30
- Updated: Merged
request_pathandrequest_pathParamsintorequest_paths. request_paths: returns the request path parts as JSON_DUPLICATE_KEYS object - Updated: Fixed issues related to encoding
TP-HTTP-Request-Response-Parser v2025.8.30
- Support for parsing and reconstructing HTTP Request/ Response
- Access all HTTP fields as JSON_DUPLICATE_KEYS objects
- Automatic Content-Length update on unparse
Metadata
Release files for tp-http-request-response-parser 2026.5.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tp_http_request_response_parser-2026.5.18.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tp_http_request_response_parser-2026.5.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.1 kB
Release files / tp_http_request_response_parser-2026.5.18.tar.gz
| Download URL | tp_http_request_response_parser-2026.5.18.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f7b4e87cb133a8fde151337a40d6f60fec9cde9fbbf008a29ca11b4473a11da
|
|
BLAKE2b-256 checksum How to use checksums |
c554e7dc2e4bf29837cd27c2512260d7a47e153bf0fdbf8aa0fabc871c382bf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.0
|
Release files / tp_http_request_response_parser-2026.5.18-py3-none-any.whl
| Download URL | tp_http_request_response_parser-2026.5.18-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e0daf9e30d7fdaf446a7be9a04e36b7d7a756ee3d831870afebaba3a8c200e3
|
|
BLAKE2b-256 checksum How to use checksums |
53017171d610728d559292b8a3174ad26894592989fefcfdd929ebe05c73e7f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.0
|