flattens a collection of HTTP headers into a JSON structure for automated analysis
Project description
HeaderBreakdown
flattens a collection of HTTP headers into a JSON structure for automated analysis
Installation
pip install headerbreakdown
Example Output
- this is the summary; each of these items are accessible directly as attributes; see below
Example Usage
from headerbreakdown import HeaderBreakdown
import json
#
# SAMPLE HEADERS
#
# header with multiple Host and User-Agent values
H1 = "GET /?gws_rd=ssl HTTP/1.1\r\nHost: www.google.com\r\nHost: www.bing.com\r\nHost: www.yahoo.com\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/99.0\r\nCookie: 1P_JAR=2021-03-13-04"
# single header as a plain string (with no \r\n)
H2 = "Set-Cookie: k1=v1;k2=v2"
# normal header examples that terminate with \r\n\r\n
H3 = "HTTP/1.1 302 Found\r\nLocation: https://www.google.com/?gws_rd=ssl\r\nCache-Control: private\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sat, 13 Mar 2021 04:15:44 GMT\r\nServer: gws\r\nContent-Length: 231\r\nX-XSS-Protection: 0\r\nX-Frame-Options: SAMEORIGIN\r\nSet-Cookie: 1P_JAR=2021-03-13-04; expires=Mon, 12-Apr-2021 04:15:44 GMT; path=/; domain=.google.com; Secure; SameSite=none\r\n\r\n"
H4 = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nSet-Cookie: k1=v1;k2=v2\r\n\r\n"
H5 = "GET / HTTP/1.1\r\nHost: google.com\r\nUser-Agent: BLAHBLAH\r\nAccept: text/plain\r\n\r\n"
#
# USAGE
#
h = HeaderBreakdown(H1)
print(h.output) # dictionary
print(h.json) # string
print(h.summary)
# etc
Available Attributes (all except summary included in output and json)
# dictionaries
output
nested_output
# lists
notices
# strings
json
nested_json
direction
http_version
method
host
path
user_agent
response_code
response_phrase
summary
Releases and Updates
- 2021-04-01
- minor fix for HTTP/ detection
- 2021-03-23
- minor edits, added summary and nested_output/nested_json attributes
- 2021-03-13
- first release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
headerbreakdown-0.1.2.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for headerbreakdown-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a0d762c27b02a284e25fc01750b7b6185385bd7a47a2ebe1d5efcef6fa5fcbb |
|
MD5 | f936ce42d7ccdf710a4e108dae06280b |
|
BLAKE2b-256 | fb25d1c395554bc03a23ddf4a5b30c2dea5fdce57f72706a34bed63d5e8fcea5 |