Parse the raw HTTP Request/ Response to the Object
Project description
TP-HTTP-Request-Response-Parser
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(rawRequest)
print("- request_method:", RequestParser.request_method)
print("- request_path:", RequestParser.request_path)
print("- request_query:", RequestParser.request_query.dumps(indent=4))
print("- request_fragment:", RequestParser.request_fragment)
print("- request_headers:", RequestParser.request_headers.dumps(indent=4))
print("- request_body:", RequestParser.request_body)
# 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(rawResponse)
print("- status_code:", ResponseParser.status_code)
print("- status_text:", ResponseParser.status_text)
print("- response_headers:", ResponseParser.response_headers.dumps(indent=4))
print("- response_body:", ResponseParser.response_body)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for TP-HTTP-Request-Response-Parser-2023.10.28.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f82f5c041b81d21b359ebc63c38894306ab42d23e0bd34c9a590ee2d23cef675 |
|
MD5 | f52e132a8917567f3a9abc13bbc1d502 |
|
BLAKE2b-256 | 9c363d2962b17de5bfa12cc56a9b3c348ce5f87994c42e22225ee161c039733f |
Close
Hashes for TP_HTTP_Request_Response_Parser-2023.10.28-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a464af2d6732e883f7bd1207e7ea9f16c03dd72a1439af6f94c95bc0ab53f98c |
|
MD5 | 9b60a1470b5534a37d4e2c2acee8f402 |
|
BLAKE2b-256 | ca1285b95c363debca4547c123e55d91d854eca1e32d583edc8cd8a4a7bb9f24 |