# TP-HTTP-Request-Response-Parser - PyPI
Parse/ Unparse the HTTP Request/ Response
<p align="center">
<a href="https://github.com/truocphan/TP-HTTP-Request-Response-Parser/releases/"><img src="https://img.shields.io/github/release/truocphan/TP-HTTP-Request-Response-Parser" height=30></a>
<a href="#"><img src="https://img.shields.io/github/downloads/truocphan/TP-HTTP-Request-Response-Parser/total" height=30></a>
<a href="#"><img src="https://img.shields.io/github/stars/truocphan/TP-HTTP-Request-Response-Parser" height=30></a>
<a href="#"><img src="https://img.shields.io/github/forks/truocphan/TP-HTTP-Request-Response-Parser" height=30></a>
<a href="https://github.com/truocphan/TP-HTTP-Request-Response-Parser/issues?q=is%3Aopen+is%3Aissue"><img src="https://img.shields.io/github/issues/truocphan/TP-HTTP-Request-Response-Parser" height=30></a>
<a href="https://github.com/truocphan/TP-HTTP-Request-Response-Parser/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed/truocphan/TP-HTTP-Request-Response-Parser" height=30></a>
</p>
## Installation
#### From PyPI:
```console
pip install TP-HTTP-Request-Response-Parser
```
#### From Source:
```console
git clone https://github.com/truocphan/TP-HTTP-Request-Response-Parser.git --branch <Branch/Tag>
cd TP-HTTP-Request-Response-Parser
python setup.py build
python setup.py install
```
## Basic Usage
```
from TP_HTTP_Request_Response_Parser import *
# Parsing HTTP Request
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
"""
# RequestParser = TP_HTTP_REQUEST_PARSER(open("request.txt", encoding="utf-8", errors="ignore").read()
RequestParser = TP_HTTP_REQUEST_PARSER(rawRequest, ordered_dict=True)
print("- request_method: {}".format(RequestParser.request_method))
print("- request_path: {}".format(RequestParser.request_path))
print("- request_pathParams: {}".format(RequestParser.request_pathParams.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_body: {}".format(RequestParser.request_body.dumps(indent=4)))
print(RequestParser.unparse(update_content_length=True))
# Parsing HTTP Response
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":[]}"""
# ResponseParser = TP_HTTP_RESPONSE_PARSER(open("response.txt", encoding="utf-8", errors="ignore").read())
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_body: {}".format(ResponseParser.response_body.dumps(indent=4)))
print(ResponseParser.unparse(update_content_length=True))
```
Raw data
{
"_id": null,
"home_page": "https://github.com/truocphan/TP-HTTP-Request-Response-Parser",
"name": "TP-HTTP-Request-Response-Parser",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "TPCyberSec, HTTP Request Parser, HTTP Response Parser",
"author": "TP Cyber Security",
"author_email": "tpcybersec2023@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c8/95/48dda736dd1c2b6e6393965930f918c56f701c873f69055fd813785c2dfe/tp_http_request_response_parser-2024.11.28.tar.gz",
"platform": null,
"description": "# TP-HTTP-Request-Response-Parser - PyPI\nParse/ Unparse the HTTP Request/ Response\n\n<p align=\"center\">\n <a href=\"https://github.com/truocphan/TP-HTTP-Request-Response-Parser/releases/\"><img src=\"https://img.shields.io/github/release/truocphan/TP-HTTP-Request-Response-Parser\" height=30></a>\n\t<a href=\"#\"><img src=\"https://img.shields.io/github/downloads/truocphan/TP-HTTP-Request-Response-Parser/total\" height=30></a>\n\t<a href=\"#\"><img src=\"https://img.shields.io/github/stars/truocphan/TP-HTTP-Request-Response-Parser\" height=30></a>\n\t<a href=\"#\"><img src=\"https://img.shields.io/github/forks/truocphan/TP-HTTP-Request-Response-Parser\" height=30></a>\n\t<a href=\"https://github.com/truocphan/TP-HTTP-Request-Response-Parser/issues?q=is%3Aopen+is%3Aissue\"><img src=\"https://img.shields.io/github/issues/truocphan/TP-HTTP-Request-Response-Parser\" height=30></a>\n\t<a href=\"https://github.com/truocphan/TP-HTTP-Request-Response-Parser/issues?q=is%3Aissue+is%3Aclosed\"><img src=\"https://img.shields.io/github/issues-closed/truocphan/TP-HTTP-Request-Response-Parser\" height=30></a>\n</p>\n\n## Installation\n#### From PyPI:\n```console\npip install TP-HTTP-Request-Response-Parser\n```\n#### From Source:\n```console\ngit clone https://github.com/truocphan/TP-HTTP-Request-Response-Parser.git --branch <Branch/Tag>\ncd TP-HTTP-Request-Response-Parser\npython setup.py build\npython setup.py install\n```\n\n## Basic Usage\n```\nfrom TP_HTTP_Request_Response_Parser import *\n\n# Parsing HTTP Request\nrawRequest = \"\"\"GET /v1/promo/extension HTTP/2\nHost: d2y7f743exec8w.cloudfront.net\nAccept-Encoding: gzip, deflate\nAccept: */*\nAccept-Language: en-US;q=0.9,en;q=0.8\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.97 Safari/537.36\nConnection: close\nCache-Control: max-age=0\n\n\"\"\"\n\n# RequestParser = TP_HTTP_REQUEST_PARSER(open(\"request.txt\", encoding=\"utf-8\", errors=\"ignore\").read()\nRequestParser = TP_HTTP_REQUEST_PARSER(rawRequest, ordered_dict=True)\n\nprint(\"- request_method: {}\".format(RequestParser.request_method))\nprint(\"- request_path: {}\".format(RequestParser.request_path))\nprint(\"- request_pathParams: {}\".format(RequestParser.request_pathParams.dumps(indent=4)))\nprint(\"- request_queryParams: {}\".format(RequestParser.request_queryParams.dumps(indent=4)))\nprint(\"- request_fragment: {}\".format(RequestParser.request_fragment))\nprint(\"- request_httpVersion: {}\".format(RequestParser.request_httpVersion))\nprint(\"- request_headers: {}\".format(RequestParser.request_headers.dumps(indent=4)))\nprint(\"- request_body: {}\".format(RequestParser.request_body.dumps(indent=4)))\nprint(RequestParser.unparse(update_content_length=True))\n\n\n\n# Parsing HTTP Response\nrawResponse = \"\"\"HTTP/2 200 OK\nContent-Type: application/json; charset=utf-8\nServer: nginx\nDate: Mon, 21 Aug 2023 03:55:08 GMT\nEtag: W/\"846e0a9b390c273d2d7a6843085411d1\"\nCache-Control: max-age=0, private, must-revalidate\nX-Request-Id: 06024e22-f233-4517-b0f6-f444c8464e7b\nStrict-Transport-Security: max-age=63072000; includeSubDomains\nStrict-Transport-Security: max-age=63072000; preload\nVary: Accept-Encoding,Accept\nX-Cache: Miss from cloudfront\nVia: 1.1 19175f36fb9c16ba394561bae28598da.cloudfront.net (CloudFront)\nX-Amz-Cf-Pop: SGN50-P2\nX-Amz-Cf-Id: eKssgTNGDCswPiQtSYFD1MRNBJCTHEbnQp4MQjtQx2B4eM7oqXYIHg==\n\n{\"ok\":true,\"promo\":[]}\"\"\"\n\n# ResponseParser = TP_HTTP_RESPONSE_PARSER(open(\"response.txt\", encoding=\"utf-8\", errors=\"ignore\").read())\nResponseParser = TP_HTTP_RESPONSE_PARSER(rawResponse, ordered_dict=True)\n\nprint(\"- response_httpVersion: {}\".format(ResponseParser.response_httpVersion))\nprint(\"- response_statusCode: {}\".format(ResponseParser.response_statusCode))\nprint(\"- response_statusText: {}\".format(ResponseParser.response_statusText))\nprint(\"- response_headers: {}\".format(ResponseParser.response_headers.dumps(indent=4)))\nprint(\"- response_body: {}\".format(ResponseParser.response_body.dumps(indent=4)))\nprint(ResponseParser.unparse(update_content_length=True))\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse/ Unparse the HTTP Request/ Response",
"version": "2024.11.28",
"project_urls": {
"Homepage": "https://github.com/truocphan/TP-HTTP-Request-Response-Parser"
},
"split_keywords": [
"tpcybersec",
" http request parser",
" http response parser"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a1a15591f5d0b0ee8fe44ca5d7490ad6c26c77f2f10151390bb575346858e00e",
"md5": "db3d2366b69315face5234cf3a559f33",
"sha256": "fda27e8d173bceed5d22edfec7d7a56fb6e26dc857b1505ff00615cef2379f7d"
},
"downloads": -1,
"filename": "TP_HTTP_Request_Response_Parser-2024.11.28-py2-none-any.whl",
"has_sig": false,
"md5_digest": "db3d2366b69315face5234cf3a559f33",
"packagetype": "bdist_wheel",
"python_version": "py2",
"requires_python": null,
"size": 6904,
"upload_time": "2024-11-28T03:21:17",
"upload_time_iso_8601": "2024-11-28T03:21:17.074884Z",
"url": "https://files.pythonhosted.org/packages/a1/a1/5591f5d0b0ee8fe44ca5d7490ad6c26c77f2f10151390bb575346858e00e/TP_HTTP_Request_Response_Parser-2024.11.28-py2-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4cdecfbd65481f01c12e405167cb304a2505fd60f31392004a4d22a1ead43ccc",
"md5": "4c57b6654e14111e42b3e1381d23860d",
"sha256": "e85f09b7b53bc1f2d99117efde0c598f8962b0a901bf195ef53b3d8e49a1fc6a"
},
"downloads": -1,
"filename": "TP_HTTP_Request_Response_Parser-2024.11.28-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4c57b6654e14111e42b3e1381d23860d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6925,
"upload_time": "2024-11-28T03:21:19",
"upload_time_iso_8601": "2024-11-28T03:21:19.393370Z",
"url": "https://files.pythonhosted.org/packages/4c/de/cfbd65481f01c12e405167cb304a2505fd60f31392004a4d22a1ead43ccc/TP_HTTP_Request_Response_Parser-2024.11.28-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c89548dda736dd1c2b6e6393965930f918c56f701c873f69055fd813785c2dfe",
"md5": "f48410bc360f4feb0b456133389c0941",
"sha256": "a4fd7befa48400709a9f79e151c7e5b50b688eaa0f92fbcaffbfc34bf2a2186e"
},
"downloads": -1,
"filename": "tp_http_request_response_parser-2024.11.28.tar.gz",
"has_sig": false,
"md5_digest": "f48410bc360f4feb0b456133389c0941",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6869,
"upload_time": "2024-11-28T03:21:21",
"upload_time_iso_8601": "2024-11-28T03:21:21.095273Z",
"url": "https://files.pythonhosted.org/packages/c8/95/48dda736dd1c2b6e6393965930f918c56f701c873f69055fd813785c2dfe/tp_http_request_response_parser-2024.11.28.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 03:21:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "truocphan",
"github_project": "TP-HTTP-Request-Response-Parser",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "json-duplicate-keys",
"specs": [
[
">=",
"2024.11.28"
]
]
}
],
"lcname": "tp-http-request-response-parser"
}